add preact with webpack

This commit is contained in:
Thomas Ruoff
2017-02-15 00:46:54 +01:00
parent 316d05790b
commit 7668fc3837
15 changed files with 229 additions and 3 deletions

47
config/setup.js Normal file
View File

@@ -0,0 +1,47 @@
const { join } = require('path');
const webpack = require('webpack');
const Dashboard = require('webpack-dashboard/plugin');
const Clean = require('clean-webpack-plugin');
const Copy = require('copy-webpack-plugin');
const HTML = require('html-webpack-plugin');
const uglify = require('./uglify');
const babel = require('./babel');
const root = join(__dirname, '..');
module.exports = isProd => {
// base plugins array
const plugins = [
new Clean(['dist'], { root }),
new Copy([{ context: 'webapp/static/', from: '**/*.*' }]),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development')
}),
new HTML({ template: 'webapp/index.html' }),
new webpack.LoaderOptionsPlugin({
options: {
babel
}
})
];
if (isProd) {
plugins.push(
new webpack.LoaderOptionsPlugin({ minimize: true, debug: false }),
new webpack.optimize.UglifyJsPlugin(uglify)
);
} else {
// dev only
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.DefinePlugin({
__DEVELOPMENT__: !isProd
}),
new Dashboard()
);
}
return plugins;
};