initial commit. work on ui
This commit is contained in:
99
webpack.config.js
Normal file
99
webpack.config.js
Normal file
@@ -0,0 +1,99 @@
|
||||
var MinifyPlugin = require('babel-minify-webpack-plugin');
|
||||
var Nunjucks = require('nunjucks');
|
||||
var fs = require('fs');
|
||||
var htmlMinify = require('html-minifier').minify;
|
||||
var ip = require('ip');
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
// Set up templating.
|
||||
var nunjucks = Nunjucks.configure(path.resolve(__dirname, 'src'), {
|
||||
noCache: true,
|
||||
});
|
||||
nunjucks.addGlobal('HOST', ip.address());
|
||||
|
||||
// Initial Nunjucks render.
|
||||
var context = {IS_PRODUCTION: process.env.NODE_ENV === 'production'};
|
||||
fs.writeFileSync('index.html', nunjucks.render('index.html', context));
|
||||
|
||||
// For development, watch HTML for changes to compile Nunjucks.
|
||||
// The production Express server will handle Nunjucks by itself.
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
fs.watch('src', { recursive: true }, (eventType, filename) => {
|
||||
if (filename.indexOf('.html') === -1) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fs.writeFileSync('index.html', nunjucks.render('index.html', context));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PLUGINS = [new webpack.EnvironmentPlugin(['NODE_ENV'])];
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
PLUGINS.push(
|
||||
new MinifyPlugin(
|
||||
{
|
||||
booleans: true,
|
||||
builtIns: true,
|
||||
consecutiveAdds: true,
|
||||
deadcode: true,
|
||||
evaluate: false,
|
||||
flipComparisons: true,
|
||||
guards: true,
|
||||
infinity: true,
|
||||
mangle: false,
|
||||
memberExpressions: true,
|
||||
mergeVars: true,
|
||||
numericLiterals: true,
|
||||
propertyLiterals: true,
|
||||
regexpConstructors: true,
|
||||
removeUndefined: true,
|
||||
replace: true,
|
||||
simplify: true,
|
||||
simplifyComparisons: true,
|
||||
typeConstructors: true,
|
||||
undefinedToVoid: true,
|
||||
keepFnName: true,
|
||||
keepClassName: true,
|
||||
tdz: true,
|
||||
},
|
||||
{
|
||||
sourceMap: 'source-map',
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
devtool: '#inline-source-map',
|
||||
devServer: {
|
||||
disableHostCheck: true,
|
||||
},
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: 'build/build.js',
|
||||
},
|
||||
plugins: PLUGINS,
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js/,
|
||||
exclude: path =>
|
||||
path.indexOf('node_modules') !== -1 || path.indexOf('panel') !== -1,
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
{
|
||||
test: /\.glsl/,
|
||||
exclude: /(node_modules)/,
|
||||
loader: 'webpack-glsl-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: [path.join(__dirname, 'node_modules')],
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user