Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// --------------------------------------
if (nuxtOptions.dev) {
// Add HMR support
config.entry.app = [HMR_CLIENT, config.entry.app];
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://webpack.js.org/plugins/named-modules-plugin
new webpack.NamedModulesPlugin()
);
// Add friendly error plugin
if (!nuxtOptions.build.quiet && nuxtOptions.build.friendlyErrors) {
config.plugins.push(
new FriendlyErrorsWebpackPlugin({
clearConsole: false,
reporter: "consola",
logLevel: "WARNING"
})
);
}
} else {
// --------------------------------------
// Production specific config
// --------------------------------------
// Minify and optimize the JavaScript
config.plugins.push(
// This is needed in webpack 2 for minify CSS
new webpack.LoaderOptionsPlugin({
minimize: true
})
})
// Add HMR support
if (this.dev) {
config.entry.app.unshift(
// https://github.com/webpack-contrib/webpack-hot-middleware/issues/53#issuecomment-162823945
'eventsource-polyfill',
// https://github.com/glenjamin/webpack-hot-middleware#config
`webpack-hot-middleware/client?${hotMiddlewareClientOptionsStr}`
)
}
// Add friendly error plugin
if (this.dev && !quiet && friendlyErrors) {
config.plugins.push(
new FriendlyErrorsWebpackPlugin({
clearConsole: false,
reporter: 'consola',
logLevel: 'WARNING'
})
)
}
return config
}
}