diff --git a/lib/builder/webpack/base.config.mjs b/lib/builder/webpack/base.mjs similarity index 95% rename from lib/builder/webpack/base.config.mjs rename to lib/builder/webpack/base.mjs index 6e801eb521..9f8a312d34 100644 --- a/lib/builder/webpack/base.config.mjs +++ b/lib/builder/webpack/base.mjs @@ -9,19 +9,11 @@ import VueLoader from 'vue-loader' import { isUrl, urlJoin } from '../../common/utils' import customLoaders from './loaders' -import createStyleLoader from './style-loader' +import createStyleLoader from './utils/style-loader' import WarnFixPlugin from './plugins/warnfix' import ProgressPlugin from './plugins/progress' import StatsPlugin from './plugins/stats' -/* -|-------------------------------------------------------------------------- -| Webpack Shared Config -| -| This is the config which is extended by the server and client -| webpack config files -|-------------------------------------------------------------------------- -*/ export default class WebpackBaseConfig { constructor(builder, options) { this.name = options.name diff --git a/lib/builder/webpack/client.config.mjs b/lib/builder/webpack/client.mjs similarity index 72% rename from lib/builder/webpack/client.config.mjs rename to lib/builder/webpack/client.mjs index 9f088edb78..55eb74e4a7 100644 --- a/lib/builder/webpack/client.config.mjs +++ b/lib/builder/webpack/client.mjs @@ -1,25 +1,13 @@ import path from 'path' import webpack from 'webpack' - import HTMLPlugin from 'html-webpack-plugin' import BundleAnalyzer from 'webpack-bundle-analyzer' import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import Debug from 'debug' +import VueSSRClientPlugin from './plugins/vue/client' import BaseConfig from './base.config' -// import VueSSRClientPlugin from 'vue-server-renderer/client-plugin' -import VueSSRClientPlugin from './plugins/vue/client' - -const debug = Debug('nuxt:build') -debug.color = 2 // Force green color - -/* -|-------------------------------------------------------------------------- -| Webpack Client Config -|-------------------------------------------------------------------------- -*/ export default class WebpackClientConfig extends BaseConfig { constructor(builder) { super(builder, { name: 'client', isServer: false }) @@ -62,34 +50,25 @@ export default class WebpackClientConfig extends BaseConfig { ) if (this.options.dev) { - // -------------------------------------- - // Dev specific config - // -------------------------------------- - - // HMR plugins.push(new webpack.HotModuleReplacementPlugin()) - } else { - // -------------------------------------- - // Production specific config - // -------------------------------------- + } - // Chunks size limit - // https://webpack.js.org/plugins/aggressive-splitting-plugin/ - if (this.options.build.maxChunkSize) { - plugins.push( - new webpack.optimize.AggressiveSplittingPlugin({ - minSize: this.options.build.maxChunkSize, - maxSize: this.options.build.maxChunkSize - }) - ) - } + // Chunks size limit + // https://webpack.js.org/plugins/aggressive-splitting-plugin/ + if (!this.options.dev && this.options.build.maxChunkSize) { + plugins.push( + new webpack.optimize.AggressiveSplittingPlugin({ + minSize: this.options.build.maxChunkSize, + maxSize: this.options.build.maxChunkSize + }) + ) + } - // Webpack Bundle Analyzer - if (this.options.build.analyze) { - plugins.push( - new BundleAnalyzer.BundleAnalyzerPlugin(Object.assign({}, this.options.build.analyze)) - ) - } + // Webpack Bundle Analyzer + if (!this.options.dev && this.options.build.analyze) { + plugins.push( + new BundleAnalyzer.BundleAnalyzerPlugin(Object.assign({}, this.options.build.analyze)) + ) } // CSS extraction @@ -126,9 +105,6 @@ export default class WebpackClientConfig extends BaseConfig { } } - // -------------------------------------- - // Dev specific config - // -------------------------------------- if (this.options.dev) { // Add HMR support config.entry = [ diff --git a/lib/builder/webpack/server.config.mjs b/lib/builder/webpack/server.mjs similarity index 89% rename from lib/builder/webpack/server.config.mjs rename to lib/builder/webpack/server.mjs index 9dfc061256..a0e9d6bc3b 100644 --- a/lib/builder/webpack/server.config.mjs +++ b/lib/builder/webpack/server.mjs @@ -5,15 +5,8 @@ import webpack from 'webpack' import nodeExternals from 'webpack-node-externals' import BaseConfig from './base.config' - -// import VueSSRServerPlugin from 'vue-server-renderer/server-plugin' import VueSSRServerPlugin from './plugins/vue/server' -/* -|-------------------------------------------------------------------------- -| Webpack Server Config -|-------------------------------------------------------------------------- -*/ export default class WebpackServerConfig extends BaseConfig { constructor(builder) { super(builder, { name: 'server', isServer: true }) diff --git a/lib/builder/webpack/postcss.mjs b/lib/builder/webpack/utils/postcss.mjs similarity index 100% rename from lib/builder/webpack/postcss.mjs rename to lib/builder/webpack/utils/postcss.mjs diff --git a/lib/builder/webpack/style-loader.js b/lib/builder/webpack/utils/style-loader.js similarity index 100% rename from lib/builder/webpack/style-loader.js rename to lib/builder/webpack/utils/style-loader.js