将vendor_dll的hash放在文件名内

This commit is contained in:
zema1 2017-12-23 22:18:53 +08:00
parent a416adaa68
commit daf79c4b7c
5 changed files with 17 additions and 9 deletions

2
.gitignore vendored
View File

@ -66,5 +66,5 @@ test.vue
# build
vendor-manifest.json
vendor.dll.js
vendor.dll*.js

View File

@ -1,5 +1,6 @@
'use strict'
const path = require('path')
const glob = require('glob')
const webpack = require('webpack')
const utils = require('./utils')
const config = require('../config')
@ -10,7 +11,7 @@ function resolve (dir) {
return path.join(__dirname, '..', dir)
}
function getEntries() {
function getEntries () {
const base = {
'oj': ['./src/pages/oj/index.js'],
'admin': ['./src/pages/admin/index.js']
@ -22,6 +23,8 @@ function getEntries() {
}
return base
}
// get all entries
const entries = getEntries()
console.log("All entries: ")
Object.keys(entries).forEach(entry => {
@ -32,6 +35,11 @@ Object.keys(entries).forEach(entry => {
console.log()
})
// prepare vendor asserts
const globOptions = {cwd: resolve('static/js')};
let vendorAssets = glob.sync('vendor.dll.*.js', globOptions);
vendorAssets = vendorAssets.map(file => 'static/js/' + file)
module.exports = {
entry: entries,
@ -107,10 +115,9 @@ module.exports = {
manifest: require('./vendor-manifest.json')
}),
new HtmlWebpackIncludeAssetsPlugin({
assets: ['static/js/vendor.dll.js'],
assets: [vendorAssets[0]],
files: ['index.html', 'admin/index.html'],
append: false,
hash: true
append: false
}),
]
}

View File

@ -23,8 +23,8 @@ module.exports = {
},
output: {
path: path.join(__dirname, '../static/js'),
filename: '[name].dll.js',
library: '[name]_dll',
filename: '[name].dll.[hash:7].js',
library: '[name]_[hash]_dll',
},
plugins: [
new webpack.DefinePlugin({
@ -40,7 +40,7 @@ module.exports = {
new webpack.DllPlugin({
context: __dirname,
path: path.join(__dirname, '[name]-manifest.json'),
name: '[name]_dll',
name: '[name]_[hash]_dll',
})
]
};

View File

@ -63,6 +63,7 @@
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"glob": "^7.1.2",
"html-webpack-include-assets-plugin": "^1.0.2",
"html-webpack-plugin": "^2.30.1",
"http-proxy-middleware": "^0.17.3",

View File

@ -8,7 +8,7 @@
<meta name="renderer" content="webkit"/>
<link rel="shortcut icon" href="/public/website/favicon.ico">
<link href="static/css/loader.css" rel="stylesheet">
<link href="/static/css/loader.css" rel="stylesheet">
<script>
// IE 10 and earlier
if (window.navigator.userAgent.indexOf('MSIE ') > 0 &&