为所有的输出资源添加版本号,以解决缓存问题。 class AssetVersioningPlugin { apply(compiler) { compiler.hooks.emit.tap('AssetVersioningPlugin', (compilation) => { const version = new Date().getTime(); for (let filename in compilation.assets) { compilation.assets[`${filename}?v=${version}`] = compilation.assets[filename]; delete compilation.assets[filename]; } }); } }