Skip to content

Commit

Permalink
浏览器缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashomon511 committed Jun 26, 2019
1 parent b10a522 commit e846c13
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions build/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const commonConfig = {
new CleanWebpackPlugin(), // 打包后先清除dist文件,先于HtmlWebpackPlugin运行
],
output: {
publicPath: "/",
filename: 'bundle.js', // 打包后文件名称
path: path.resolve(__dirname, '../dist') // 打包后文件夹存放路径
}
}
Expand Down
6 changes: 5 additions & 1 deletion build/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const devConfig = {
new webpack.NamedModulesPlugin(), //用于启动HMR时可以显示模块的相对路径
new webpack.HotModuleReplacementPlugin(), // 开启模块热更新,热加载和模块热更新不同,热加载是整个页面刷新
],
output: {}
output: {
publicPath: "/",
filename: '[name].js',
chunkFilename: '[name].js',
}
}

module.exports = merge.smart(commonConfig, devConfig)
5 changes: 4 additions & 1 deletion build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const prodConfig = {
chunkFilename: '[name].chunk.css'
})
],
output: {}
output: {
filename: '[name].[contenthash].js', // entry对应的key值
chunkFilename: '[name].[contenthash].js', // 间接引用的文件会走这个配置
},
}

module.exports = merge.smart(commonConfig, prodConfig)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node ./build/dev-server.js",
"dev-build": "webpack --config ./build/webbpack.dev.js",
"dev-build": "webpack --config ./build/webpack.dev.js",
"build": "webpack --config ./build/webpack.prod.js"
},
"repository": {
Expand Down

0 comments on commit e846c13

Please sign in to comment.