mini-css-extract-plugin
Advanced tools
Comparing version
@@ -32,2 +32,6 @@ 'use strict'; | ||
const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/i; | ||
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/i; | ||
const REGEXP_NAME = /\[name\]/i; | ||
class CssDependency extends _webpack2.default.Dependency { | ||
@@ -84,2 +88,12 @@ constructor({ identifier, content, media, sourceMap }, context, identifierIndex) { | ||
updateCacheModule(module) { | ||
this.content = module.content; | ||
this.media = module.media; | ||
this.sourceMap = module.sourceMap; | ||
} | ||
needRebuild() { | ||
return true; | ||
} | ||
build(options, compilation, resolver, fileSystem, callback) { | ||
@@ -154,3 +168,4 @@ this.buildInfo = {}; | ||
}, | ||
identifier: `mini-css-extract-plugin.${chunk.id}` | ||
identifier: `mini-css-extract-plugin.${chunk.id}`, | ||
hash: chunk.contentHash[NS] | ||
}); | ||
@@ -169,6 +184,19 @@ } | ||
}, | ||
identifier: `mini-css-extract-plugin.${chunk.id}` | ||
identifier: `mini-css-extract-plugin.${chunk.id}`, | ||
hash: chunk.contentHash[NS] | ||
}); | ||
} | ||
}); | ||
compilation.mainTemplate.hooks.hashForChunk.tap(pluginName, (hash, chunk) => { | ||
const { chunkFilename } = this.options; | ||
if (REGEXP_CHUNKHASH.test(chunkFilename)) { | ||
hash.update(JSON.stringify(chunk.getChunkMaps(true).hash)); | ||
} | ||
if (REGEXP_CONTENTHASH.test(chunkFilename)) { | ||
hash.update(JSON.stringify(chunk.getChunkMaps(true).contentHash[NS] || {})); | ||
} | ||
if (REGEXP_NAME.test(chunkFilename)) { | ||
hash.update(JSON.stringify(chunk.getChunkMaps(true).name)); | ||
} | ||
}); | ||
compilation.hooks.contentHash.tap(pluginName, chunk => { | ||
@@ -175,0 +203,0 @@ const { outputOptions } = compilation; |
{ | ||
"name": "mini-css-extract-plugin", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "desc", | ||
@@ -47,3 +47,3 @@ "main": "dist/cjs.js", | ||
"standard-version": "^4.3.0", | ||
"webpack": "^4.3.0", | ||
"webpack": "^4.4.0", | ||
"webpack-cli": "^2.0.13", | ||
@@ -60,3 +60,3 @@ "webpack-defaults": "^1.6.0", | ||
"peerDependencies": { | ||
"webpack": "^4.3.0" | ||
"webpack": "^4.4.0" | ||
}, | ||
@@ -63,0 +63,0 @@ "pre-commit": "lint-staged", |
26910
3.7%413
6.44%