Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stats: 'errors-only',
devServer: { stats: 'errors-only' }
}
if (DEBUG) {
config.plugins = [
...config.plugins,
// LiveReload in development
new LiveReloadPlugin({
appendScriptTag: true
}),
// Debug mode for old webpack plugins
new webpack.LoaderOptionsPlugin({
debug: true
})
]
}
return config
}
}),
new HtmlWebpackPlugin({
title: config.title,
template: path.resolve(__dirname, '../common/index.html'),
inject: true,
filename: _.outputIndexPath
}),
new CopyWebpackPlugin([
{
from: _.cwd('./static'),
// to the root of dist path
to: './'
}
]),
new webpack.LoaderOptionsPlugin(_.loadersOptions())
],
target: _.target
};
module.exports = webpackConfig;
function plugins() {
log('Enable common plugins: Define, LoaderOptions, HtmlWebpack, CommonsChunk')
const common = [
// map variables
new webpack.DefinePlugin(clientConfig.globals),
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
cssnano({
autoprefixer: {
add: true,
remove: true,
browsers: ['last 2 versions']
},
discardComments: {
removeAll: true
},
discardUnused: false,
mergeIdents: false,
reduceIdents: false,
safe: true,
module.exports = function(env) {
if (!env) {
env = {};
}
// handle minification
if (env && env.compress) {
plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
);
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: true,
keep_fnames: true
},
mangle: {
keep_fnames: true
}
})
);
// Reference: https://github.com/angular/angular-cli/tree/master/packages/webpack
new aotplugin.AotPlugin({
tsConfigPath: './tsconfig-aot.json',
entryModule: 'app/module#AppModule',
skipCodeGeneration: true
}),
// Inject script and link tags into html files
// Reference: https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
template: './public/treeshaking-webpack/index.html',
chunksSortMode: 'dependency'
}),
new webpack.LoaderOptionsPlugin({
debug: false,
minimize: true
}),
// Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
// Only emit files when there are no errors
new webpack.NoErrorsPlugin(),
// Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
// Dedupe modules in the output
// TODO: reactivate once fixed, see https://github.com/webpack/webpack/issues/2644
//new webpack.optimize.DedupePlugin(),
// Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
// Minify all javascript, switch loaders to minimizing mode
new webpack.optimize.UglifyJsPlugin({
optimizationLevel: 1
},
svgo: {},
plugins: [] // add imagemin-mozjpeg plugin once https://github.com/sindresorhus/execa/issues/61 is available...and prob switch to image-webpack-loader
})
]
if (IS_DEV) {
plugins.push(
new Webpack.HotModuleReplacementPlugin(),
new Webpack.NamedModulesPlugin(),
new DashboardPlugin()
)
} else {
plugins.push(
new Webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new Webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true
},
}
)
}
}
/**
* Adjust rendererConfig for production settings
*/
if (process.env.NODE_ENV === 'production') {
rendererConfig.devtool = ''
rendererConfig.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.LoaderOptionsPlugin({
minimize: true
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
)
}
module.exports = rendererConfig
export function pluginsDev(template: string | false): Array {
return [
new webpack.LoaderOptionsPlugin({ debug: true }),
new webpack.DefinePlugin({ "process.env.NODE_ENV": '"development"' }),
new webpack.HotModuleReplacementPlugin(),
htmlWebpackPlugin(template)
];
}
];
devConfig.devServer = {
compress: true,
clientLogLevel: 'none',
contentBase: path.resolve('./dist'),
publicPath: '/',
quiet: true,
hot: true,
watchOptions: {
ignored: /node_modules/
},
historyApiFallback: true
};
}
plugins.push(new webpack.LoaderOptionsPlugin(loaderOptionsConfig));
const baseConfig = Object.assign({
entry: './src/js/index.js',
output: {
path: path.resolve('./dist'),
filename: 'index.js',
publicPath: '/'
},
resolve: {
extensions: ['.js', '.scss', '.css', '.json']
},
plugins,
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
];
devConfig.devServer = {
compress: true,
clientLogLevel: 'none',
contentBase: path.resolve('./dist'),
publicPath: '/',
quiet: true,
hot: true,
watchOptions: {
ignored: /node_modules/
},
historyApiFallback: true
};
}
plugins.push(new webpack.LoaderOptionsPlugin(loaderOptionsConfig));
export default Object.assign({
entry: './src/js/index.js',
output: {
path: path.resolve('./dist'),
filename: 'index.js',
publicPath: '/'
},
resolve: {
extensions: ['.js', '.scss', '.css', '.json']
},
plugins,
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'