Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 6533a80

Browse files
authored
Merge pull request #99 from ProgrammingLab/gedorinku/webpack4
Webpack 4にする
2 parents a7cfb23 + 97eb4cf commit 6533a80

File tree

5 files changed

+2640
-2534
lines changed

5 files changed

+2640
-2534
lines changed

build/webpack.base.conf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const path = require('path')
33
const utils = require('./utils')
44
const config = require('../config')
5+
const { VueLoaderPlugin } = require("vue-loader");
56
const vueLoaderConfig = require('./vue-loader.conf')
67

78
function resolve (dir) {
@@ -88,5 +89,6 @@ module.exports = {
8889
net: 'empty',
8990
tls: 'empty',
9091
child_process: 'empty'
91-
}
92+
},
93+
plugins: [new VueLoaderPlugin()]
9294
}

build/webpack.dev.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const HOST = process.env.HOST
1414
const PORT = process.env.PORT && Number(process.env.PORT)
1515

1616
const devWebpackConfig = merge(baseWebpackConfig, {
17+
mode: 'development',
1718
module: {
1819
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
1920
},

build/webpack.prod.conf.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const BrotliPlugin = require('brotli-webpack-plugin')
1515
const env = require('../config/prod.env')
1616

1717
const webpackConfig = merge(baseWebpackConfig, {
18+
mode: 'production',
1819
module: {
1920
rules: utils.styleLoaders({
2021
sourceMap: config.build.productionSourceMap,
@@ -44,7 +45,7 @@ const webpackConfig = merge(baseWebpackConfig, {
4445
}),
4546
// extract css into its own file
4647
new ExtractTextPlugin({
47-
filename: utils.assetsPath('css/[name].[contenthash].css'),
48+
filename: utils.assetsPath('css/[name].[hash].css'),
4849
// Setting the following option to `false` will not extract CSS from codesplit chunks.
4950
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
5051
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
@@ -79,35 +80,6 @@ const webpackConfig = merge(baseWebpackConfig, {
7980
new webpack.HashedModuleIdsPlugin(),
8081
// enable scope hoisting
8182
new webpack.optimize.ModuleConcatenationPlugin(),
82-
// split vendor js into its own file
83-
new webpack.optimize.CommonsChunkPlugin({
84-
name: 'vendor',
85-
minChunks (module) {
86-
// any required modules inside node_modules are extracted to vendor
87-
return (
88-
module.resource &&
89-
/\.js$/.test(module.resource) &&
90-
module.resource.indexOf(
91-
path.join(__dirname, '../node_modules')
92-
) === 0
93-
)
94-
}
95-
}),
96-
// extract webpack runtime and module manifest to its own file in order to
97-
// prevent vendor hash from being updated whenever app bundle is updated
98-
new webpack.optimize.CommonsChunkPlugin({
99-
name: 'manifest',
100-
minChunks: Infinity
101-
}),
102-
// This instance extracts shared chunks from code splitted chunks and bundles them
103-
// in a separate chunk, similar to the vendor chunk
104-
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
105-
new webpack.optimize.CommonsChunkPlugin({
106-
name: 'app',
107-
async: 'vendor-async',
108-
children: true,
109-
minChunks: 3
110-
}),
11183

11284
// copy custom static assets
11385
new CopyWebpackPlugin([
@@ -127,7 +99,12 @@ const webpackConfig = merge(baseWebpackConfig, {
12799
minRatio: 0.8,
128100
quality: 11,
129101
})
130-
]
102+
],
103+
optimization: {
104+
splitChunks: {
105+
chunks: "all"
106+
}
107+
}
131108
})
132109

133110
if (config.build.productionGzip) {

0 commit comments

Comments
 (0)