Webpack Encore:选择性或部分版本控制
我通常在 Webpack 中启用版本控制,但是有没有更有选择性的方法?
我需要保持一个或多个文件不受版本控制。
如果我可以同时拥有这些文件的版本化和非版本化版本,那就更好了。
我当前的配置:
let Encore = require('@symfony/webpack-encore');
let UglifyJsPlugin = require('uglifyjs-webpack-plugin');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableSassLoader()
.autoProvidejQuery()
// I enable the versioning
.enableVersioning(Encore.isProduction())
// But i want an unversioned build of this file
.addStyleEntry('blog_article', './assets/css/blog_article.scss')
;
const config = Encore.getWebpackConfig();
if(Encore.isProduction()) {
config.plugins.push(new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false
}
}
}));
}
module.exports = [config];
当前输出:
- app.XXX.js(版本化)
- blog_article.XXX.css(版本化)
所需输出:
- app.XXX.js(版本化)
- blog_article.XXX.css(版本化)
- blog_article.css(未版本化)
I usually enable the versioning in Webpack, but is there to do it more selectively?
I need to keep one or more files unversioned.
Even better if I could have both, versioned and unversioned builds of these files.
My current config:
let Encore = require('@symfony/webpack-encore');
let UglifyJsPlugin = require('uglifyjs-webpack-plugin');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableSassLoader()
.autoProvidejQuery()
// I enable the versioning
.enableVersioning(Encore.isProduction())
// But i want an unversioned build of this file
.addStyleEntry('blog_article', './assets/css/blog_article.scss')
;
const config = Encore.getWebpackConfig();
if(Encore.isProduction()) {
config.plugins.push(new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false
}
}
}));
}
module.exports = [config];
Current output :
- app.XXX.js (versioned)
- blog_article.XXX.css (versioned)
Desired output :
- app.XXX.js (versioned)
- blog_article.XXX.css (versioned)
- blog_article.css (unversioned)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一年过去了,这个问题可能已经解决了,但我也遇到了类似的问题。我需要从资产中的特定目录复制文件而不添加哈希。根据 Symfony webpack 文档 和 Webpack 文档,这是我的解决方案。
A year has passed, the question is probably solved, but I had a similar problem. I need to copy files from specific dir in assets without adding hash. According to Symfony webpack docs and Webpack docs, here is my solution.