mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 22:47:25 +01:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
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;
|
|
};
|