Created
March 27, 2019 05:49
-
-
Save undoZen/678f3068143daaa97ad56f3b71ed53e9 to your computer and use it in GitHub Desktop.
Taro webpack h5 build hash all assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
h5: { | |
miniCssExtractPluginOption: { | |
filename: 'css/[name].[hash].css', | |
chunkFilename: 'css/[id].[chunkhash].css' | |
}, | |
enableDll: false, | |
webpackChain(chain, webpack) { | |
const hashRule = (type) => { | |
chain.module.rules.get(type).uses.get("urlLoader").get("options").name = | |
chain.module.rules.get(type).uses.get("urlLoader").get("options").name.replace("[name].[ext]", "[name].[hash].[ext]") | |
} | |
hashRule('font') | |
hashRule('image') | |
hashRule('media') | |
chain.merge({ | |
output: { | |
filename: "[name].[chunkhash].js", | |
chunkFilename: chain.output.get("chunkFilename").replace("[name].js", "[name].[chunkhash].js"), | |
}, | |
}) | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment