Skip to content

Commit e3ccf11

Browse files
committed
dllplugin&dllReferencePlugin&htmlWebpackIncludeAssetsPlugin
1 parent a6e99af commit e3ccf11

File tree

6 files changed

+259
-2
lines changed

6 files changed

+259
-2
lines changed

optimization/project/package-lock.json

Lines changed: 182 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

optimization/project/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"serve": "vue-cli-service serve",
6+
"start": "vue-cli-service serve",
77
"build": "vue-cli-service build",
8+
"dll": "webpack -p --progress --config webpack.dll.js",
89
"lint": "vue-cli-service lint"
910
},
1011
"dependencies": {
@@ -18,8 +19,11 @@
1819
"@vue/cli-service": "^3.4.0",
1920
"@vue/eslint-config-standard": "^4.0.0",
2021
"babel-eslint": "^10.0.1",
22+
"clean-webpack-plugin": "^1.0.1",
2123
"eslint": "^5.8.0",
2224
"eslint-plugin-vue": "^5.0.0",
23-
"vue-template-compiler": "^2.5.21"
25+
"html-webpack-include-assets-plugin": "^1.0.7",
26+
"vue-template-compiler": "^2.5.21",
27+
"webpack-cli": "^3.2.3"
2428
}
2529
}

optimization/project/public/vendor/dll.lib.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"lib","content":{"../../project/node_modules/webpack/buildin/global.js":{"id":0,"buildMeta":{"providedExports":true}},"../../project/node_modules/vue/dist/vue.runtime.esm.js":{"id":2,"buildMeta":{"exportsType":"namespace","providedExports":["default"]}},"../../project/node_modules/timers-browserify/main.js":{"id":3,"buildMeta":{"providedExports":true}},"../../project/node_modules/setimmediate/setImmediate.js":{"id":4,"buildMeta":{"providedExports":true}},"../../project/node_modules/process/browser.js":{"id":5,"buildMeta":{"providedExports":true}},"../../project/node_modules/vue-router/dist/vue-router.esm.js":{"id":6,"buildMeta":{"exportsType":"namespace","providedExports":["default"]}},"../../project/node_modules/vuex/dist/vuex.esm.js":{"id":7,"buildMeta":{"exportsType":"namespace","providedExports":["default","Store","install","mapState","mapMutations","mapGetters","mapActions","createNamespacedHelpers"]}},"../../project/node_modules/lodash/lodash.js":{"id":8,"buildMeta":{"providedExports":true}},"../../project/node_modules/webpack/buildin/module.js":{"id":9,"buildMeta":{"providedExports":true}}}}

optimization/project/vue.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const path = require('path')
2+
const webpack = require('webpack')
3+
const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin')
4+
module.exports = {
5+
configureWebpack: {
6+
devServer: {
7+
open: true
8+
},
9+
plugins: [
10+
new webpack.DllReferencePlugin({
11+
context: process.cwd(),
12+
manifest: require('./public/vendor/vendor-manifest.json')
13+
}),
14+
new HtmlWebpackIncludeAssetsPlugin({
15+
assets: [path.posix.join('./vendor/dll.lib.js')],
16+
hash: true,
17+
append: false
18+
})
19+
]
20+
}
21+
}

optimization/project/webpack.dll.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const webpack = require('webpack')
2+
const path = require('path')
3+
const CleanWebpackPlugin = require('clean-webpack-plugin')
4+
const vendors = [
5+
'vue',
6+
'vue-router',
7+
'vuex',
8+
'lodash'
9+
]
10+
11+
module.exports = {
12+
entry: {
13+
lib: vendors
14+
},
15+
output: {
16+
path: path.resolve(__dirname, 'public/vendor'),
17+
filename: 'dll.[name].js',
18+
library: '[name]'
19+
},
20+
plugins: [
21+
new CleanWebpackPlugin('public/vendor/*.*'),
22+
new webpack.DllPlugin({
23+
context: path.resolve(__dirname, '../dist/js'),
24+
path: path.resolve(__dirname, 'public/vendor', 'vendor-manifest.json'),
25+
name: '[name]'
26+
})
27+
]
28+
}

0 commit comments

Comments
 (0)