您可以使用您的webpack.config.js插件下面創建一個內容哈希CSS文件:
plugins: [
new ExtractTextPlugin('styles-[contenthash].css'),
]
取樣完全的WebPack配置:
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.[chunkhash].js'
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new HtmlWebpackPlugin({template: './src/index.html'}),
new ExtractTextPlugin('styles.[contenthash].css'),
]
};
謝謝,現在工作 –