Repository URL to install this package:
|
Version:
3.1.0 ▾
|
import path from 'path';
import swig from 'swig';
import config from 'config';
const basepath = ( process.cwd() );
const swigDefaults = {
autoescape: true,
loader: swig.loaders.fs( path.resolve( path.join( basepath, 'server', 'views' ) ) ),
locals: {
app: config.has( 'app' ) ? config.get( 'app' ) : {},
},
};
export default ( app ) => {
if ( app.get( 'env' ) === 'development' ) {
app.set( 'view cache', false );
swigDefaults.cache = false;
}
if ( app.get( 'env' ) === 'production' ) {
swigDefaults.cache = 'memory';
}
swig.setDefaults( swigDefaults );
app.engine( 'html', swig.renderFile );
app.set( 'views', path.resolve( path.join( basepath, 'server', 'views' ) ) );
};