Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exclude: /a\.js|node_modules/,
// show a warning when there is a circular dependency
failOnError: false,
})
: null,
_IS_DEV_
? new WriteFilePlugin({
exitOnErrors: false,
log: true,
// required not to cache removed files
useHashIndex: false,
})
: null,
_IS_CLIENT_ ? new ExtractCssChunks() : null,
_IS_SERVER_ ? new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }) : null,
_IS_PROD_ ? new webpack.optimize.ModuleConcatenationPlugin() : null,
// "Use HashedModuleIdsPlugin to generate IDs that preserves over builds."
// @see: https://github.com/webpack/webpack.js.org/issues/652#issuecomment-273324529
_IS_PROD_ && _IS_CLIENT_ ? new webpack.HashedModuleIdsPlugin() : null,
// Extract Webpack bootstrap code with knowledge about chunks into separate cachable package.
// explicit-webpack-runtime-chunk
_IS_CLIENT_ && _IS_PROD_
? new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: module => /node_modules/.test(module.resource),
})
: null,
// Extract Webpack bootstrap code with knowledge about chunks into separate cachable package.
limit: 1000, // 1 KO
name: "public/fonts/[name].[hash:7].[ext]"
}
}
]
},
resolve: {
alias: {
extensions: EXTENSIONS_DIR
}
},
plugins: [
// CSS extraction)
...(nuxtOptions.build.extractCSS
? [
new ExtractCssChunksPlugin(
Object.assign(
{
filename: CSS_FILENAME,
chunkFilename: CSS_FILENAME,
// TODO: https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/132
reloadAll: true
},
nuxtOptions.build.extractCSS
)
)
]
: []),
new HTMLPlugin({
title: PAGE_TITLE,
filename: "index.html",
template: PAGE_TEMPLATE,
],
runtimeChunk: isClient && {
name: 'bootstrap',
},
splitChunks: isClient && {
chunks: 'initial',
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
},
},
},
},
plugins: [
isClient && new ExtractCssChunks(),
isServer &&
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
isClient && isDev && new webpack.HotModuleReplacementPlugin(),
isClient && isProd && new StatsPlugin('stats.json'),
isClient && isProd && new webpack.HashedModuleIdsPlugin(), // not needed for strategy to work (just good practice)
new WriteFilePlugin(),
].filter(Boolean),
}
}
let extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
chunkFilename: '[id].[chunkHash:8].css',
})
if (!config.extractCssChunks) {
splitChunks.cacheGroups = {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
}
extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
})
}
return {
mode: 'production',
context: path.resolve(__dirname, '../../../node_modules'),
entry: path.resolve(ROOT, config.entry),
output: {
filename: '[name].[hash:8].js', // dont use chunkhash, its not a chunk
chunkFilename: 'templates/[name].[chunkHash:8].js',
path: ASSETS,
publicPath: process.env.REACT_STATIC_ASSETS_PATH || '/',
},
optimization: {
minimize: true,
minimizer: [
}
: {},
modules: [
path.resolve(__dirname, '../../../node_modules'),
'node_modules',
NODE_MODULES,
SRC,
DIST,
],
extensions: ['.js', '.json', '.jsx'],
},
plugins: [
new webpack.EnvironmentPlugin(process.env),
!isNode &&
(config.extractCssChunks
? new ExtractCssChunks()
: new ExtractTextPlugin({
filename: getPath => {
process.env.extractedCSSpath = getPath('styles.[hash:8].css')
return process.env.extractedCSSpath
},
allChunks: true,
})),
new CaseSensitivePathsPlugin(),
!isNode &&
new webpack.optimize.CommonsChunkPlugin({
name: 'bootstrap', // Named bootstrap to support the webpack-flush-chunks plugin
minChunks: Infinity,
}),
isNode &&
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
let extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
chunkFilename: '[id].[chunkHash:8].css',
})
if (!config.extractCssChunks) {
splitChunks.cacheGroups = {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
}
extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
})
}
return {
mode: 'production',
context: path.resolve(__dirname, '../../../node_modules'),
entry: config.disableRuntime
? config.entry
: [
require.resolve('../../bootstrapPlugins'),
require.resolve('../../bootstrapTemplates'),
require.resolve('../../bootstrapApp'),
],
output: {
filename: '[name].[hash:8].js', // dont use chunkhash, its not a chunk
plugins () {
const plugins = []
const { nuxt, buildOptions } = this.buildContext
// Add timefix-plugin before others plugins
if (this.dev) {
plugins.push(new TimeFixPlugin())
}
// CSS extraction)
if (buildOptions.extractCSS) {
plugins.push(new ExtractCssChunksPlugin(Object.assign({
filename: this.getFileName('css'),
chunkFilename: this.getFileName('css')
}, buildOptions.extractCSS)))
}
plugins.push(new VueLoader.VueLoaderPlugin())
plugins.push(...(buildOptions.plugins || []))
plugins.push(new WarningIgnorePlugin(this.warningIgnoreFilter()))
// Build progress indicator
plugins.push(new WebpackBar({
name: this.name,
color: this.colors[this.name],
reporters: [
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'all',
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
}
let extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
chunkFilename: '[id].[chunkHash:8].css',
})
if (!config.extractCssChunks) {
splitChunks.cacheGroups = {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
}
extrackCSSChunks = new ExtractCssChunks({
filename: '[name].[chunkHash:8].css',
})
config.plugins.forEach((plugin, index) => {
if (plugin instanceof ExtractCSS) {
config.plugins[index] = new ExtractCSS({
filename: getPath => {
process.env.extractedCSSpath = 'styles.css'
return getPath('styles.css')
},
})
}
})
}