Skip to content

Commit 87cac68

Browse files
author
benholloway
committed
add md5 hash plugin, revert extract chunk-manifest plugin
1 parent 548842a commit 87cac68

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

config/add/common.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var webpack = require('webpack'),
77
ExtractTextPlugin = require('extract-text-webpack-plugin'),
88
BowerWebpackPlugin = require('bower-webpack-plugin'),
99
EntryGeneratorPlugin = require('entry-generator-webpack-plugin'),
10-
OmitTildePlugin = require('omit-tilde-webpack-plugin');
10+
OmitTildePlugin = require('omit-tilde-webpack-plugin'),
11+
Md5HashPlugin = require('webpack-md5-hash');
1112

1213
/**
1314
* Add configuration common to all modes.
@@ -83,17 +84,23 @@ function common(loaderRoot, options) {
8384
.loader('image', {
8485
test : /\.(jpe?g|png|gif|svg)([#?].*)?$/i,
8586
loaders: [
86-
'file?hash=sha512&digest=hex&name=[hash].[ext]',
87+
'file?name=[md5:hash:hex:20].[ext]',
8788
'image-webpack?optimizationLevel=7&interlaced=false'
8889
]
8990
})
90-
.loader('woff', {
91-
test : /\.woff2?([#?].*)?$/i,
92-
loader: 'url?limit=10000&mimetype=application/font-woff&name=[hash].[ext]'
91+
.loader('icon', {
92+
test : /\.ico([#?].*)?$/i,
93+
loaders: [
94+
'file?name=[md5:hash:hex:20].[ext]'
95+
]
9396
})
9497
.loader('font', {
95-
test : /\.(eot|ttf|ico|otf)([#?].*)?$/i,
96-
loader: 'file?name=[hash].[ext]'
98+
test : /\.(eot|ttf|otf)([#?].*)?$/i,
99+
loader: 'file?name=[md5:hash:hex:20].[ext]'
100+
})
101+
.loader('woff', { // NB: I coppied this from somewhere, not sure why we would embed woff and not other fonts
102+
test : /\.woff2?([#?].*)?$/i,
103+
loader: 'url?limit=10000&mimetype=application/font-woff&name=[md5:hash:hex:20].[ext]'
97104
})
98105
.loader('js-bower', {
99106
test : /\.js$/i,
@@ -108,11 +115,12 @@ function common(loaderRoot, options) {
108115
exclude: /[\\\/](bower_components|webpack|css-loader)[\\\/]/i,
109116
loaders: [
110117
'ng-annotate?sourceMap',
111-
'adjust-sourcemap?format=absolute', // fix ng-annotate source maps in Windows but tweaking incoming map
118+
// fix ng-annotate source maps in Windows but using absolute paths in incoming source-map
119+
'adjust-sourcemap?format=absolute',
112120
'nginject?sourceMap&deprecate&singleQuote',
113-
'babel?sourceMap&ignore=buffer&compact=false'
114121
// https://github.com/feross/buffer/issues/79
115122
// http://stackoverflow.com/a/29857361/5535360
123+
'babel?sourceMap&ignore=buffer&compact=false'
116124
]
117125
})
118126
.loader('html', {
@@ -134,24 +142,26 @@ function common(loaderRoot, options) {
134142
deprecate: true
135143
}])
136144
.plugin('bower', BowerWebpackPlugin, [{
137-
includes : /\.((js|css)|(woff2?|eot|ttf|otf)([#?].*)?)$/i,
145+
includes : /\.((js|css)|(jpe?g|png|gif|svg|ico)|(woff2?|eot|ttf|otf)([#?].*)?)$/i,
138146
searchResolveModulesDirectories: false
139147
}])
140148

141149
// globals
142150
.plugin('provide', webpack.ProvidePlugin, [options.globals])
143151

144152
// output, chunking, optimisation
153+
// https://github.com/webpack/webpack/issues/1315#issuecomment-139930039
145154
.plugin('extract-text', ExtractTextPlugin, [
146155
undefined,
147-
'[name].[contenthash].css',
156+
'[name].[md5:contenthash:hex:20].css',
148157
{allChunks: true}
149158
])
150159
.plugin('commons', webpack.optimize.CommonsChunkPlugin, [{
151160
name : 'vendor',
152161
minChunks: Infinity
153162
}])
154-
.plugin('occurence-order', webpack.optimize.OccurenceOrderPlugin);
163+
.plugin('occurence-order', webpack.optimize.OccurenceOrderPlugin)
164+
.plugin('md5-hash', Md5HashPlugin);
155165
}
156166

157167
module.exports = common;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"browser-sync": "^2.11.1",
2727
"browser-sync-webpack-plugin": "^1.0.1",
2828
"camelcase": "^2.1.0",
29-
"chunk-manifest-webpack-plugin": "github:bholloway/chunk-manifest-webpack-plugin",
29+
"chunk-manifest-webpack-plugin": "0.0.1",
3030
"clean-webpack-plugin": "^0.1.7",
3131
"cross-env": "^1.0.7",
3232
"css-loader": "^0.23.1",
@@ -53,6 +53,7 @@
5353
"sass-loader": "^3.1.2",
5454
"url-loader": "^0.5.7",
5555
"webpack": "^1.12.12",
56-
"webpack-configurator": "^0.3.1"
56+
"webpack-configurator": "^0.3.1",
57+
"webpack-md5-hash": "0.0.5"
5758
}
5859
}

0 commit comments

Comments
 (0)