Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf274f6e

Browse files
committed
配置dll
1 parentbe58adc commitf274f6e

File tree

6 files changed

+66
-23
lines changed

6 files changed

+66
-23
lines changed

‎build/webpack.base.conf.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const vueLoaderConfig = require('./vue-loader.conf')
66
constHappyPack=require('happypack');
77
constos=require('os')
88
consthappyThreadPool=HappyPack.ThreadPool({size:os.cpus().length});
9+
constwebpack=require('webpack')
910

1011
functionresolve(dir){
1112
returnpath.join(__dirname,'..',dir)
@@ -33,7 +34,7 @@ module.exports = {
3334
},
3435
output:{
3536
path:config.build.assetsRoot,// 导出目录的绝对路径 在项目的根目录下 会新建dist文件夹
36-
filename:'[name].js',// 导出文件的文件名
37+
filename:'[name].[hash].js',// 导出文件的文件名
3738
publicPath:process.env.NODE_ENV==='production'
3839
?config.build.assetsPublicPath
3940
:config.dev.assetsPublicPath
@@ -104,7 +105,11 @@ module.exports = {
104105
threadPool:happyThreadPool,
105106
//允许 HappyPack 输出日志
106107
verbose:true,
107-
})
108+
}),
109+
newwebpack.DllReferencePlugin({
110+
context:__dirname,
111+
manifest:require('../static/js/vendor-manifest.json')// 指向生成的manifest.json
112+
}),
108113
],
109114
node:{
110115
// prevent webpack from injecting useless setImmediate polyfill because Vue

‎build/webpack.dll.conf.js‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
constpath=require('path');
22
constwebpack=require('webpack');
3-
constCleanWebpackPlugin=require("clean-webpack-plugin");
4-
53
module.exports={
64
entry:{
7-
vendor:[
8-
'vue',
9-
'vue-router',
10-
'vuex',
11-
'axios',
12-
'element-ui',
13-
]
5+
vendor:
6+
['vue/dist/vue.esm.js',
7+
'vue-router',
8+
'vuex',
9+
'axios',
10+
'element-ui',
11+
]
1412
},
1513
output:{
16-
filename:'[name]_dll_[hash:6].js',// 产生的文件名
17-
path:path.resolve(__dirname,'../static/dll'),
18-
library:'[name]_dll_[hash:6]'
14+
path:path.join(__dirname,'../static/js'),
15+
filename:'[name].dll.js',
16+
library:"[name]_library"//这个名称和下面的name值必须一样
1917
},
2018
plugins:[
21-
newCleanWebpackPlugin({
22-
root:path.resolve(__dirname,'../static/dll'),
23-
dry:false// 启用删除文件
24-
}),
2519
newwebpack.DllPlugin({
26-
name:'[name]_dll_[hash:6]',
27-
path:path.resolve(__dirname,'../static/dll','[name].dll.manifest.json')
20+
path:path.join(__dirname,"../static/js/[name]-manifest.json"),
21+
name:"[name]_library"//这个名称和上面的library值必须一样
22+
}),
23+
// 压缩打包的文件,与该文章主线无关
24+
newwebpack.optimize.UglifyJsPlugin({
25+
compress:{
26+
warnings:false
27+
}
2828
})
2929
]
30-
};
30+
}

‎index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<metaname="viewport"content="width=device-width,initial-scale=1.0">
77
<title>vue-demo</title>
88
<scripttype="text/javascript"src="/static/live2dw/lib/L2Dwidget.min.js"></script>
9+
<scriptsrc="./static/js/vendor.dll.js"></script>
910
</head>
1011

1112
<body>

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"e2e":"node test/e2e/runner.js",
1212
"test":"npm run unit && npm run e2e",
1313
"lint":"eslint --ext .js,.vue src test/unit test/e2e/specs",
14-
"build":"node build/build.js"
14+
"build":"node build/build.js",
15+
"dll":"webpack --config build/webpack.dll.conf.js"
1516
},
1617
"dependencies": {
1718
"axios":"^0.19.2",
@@ -98,4 +99,4 @@
9899
"last 2 versions",
99100
"not ie <= 8"
100101
]
101-
}
102+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp