misc: cleanup webpack config

This commit is contained in:
Pooya Parsa 2018-03-22 20:47:24 +04:30
parent d5462ea65a
commit 765f560b8c
5 changed files with 18 additions and 57 deletions

View File

@ -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

View File

@ -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 = [

View File

@ -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 })