-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
无法修改内置的 UglifyJsPlugin 、DefinePlugin 等插件参数 #58
Comments
以 var define = {
"default": {
"DATAHOST": "http://localhost",
"DEBUG": true
},
"test": {
"DATAHOST": "http://x.sit.hostname.net",
"DEBUG": true
},
"prod": {
"DATAHOST": "http://x.hostname.com",
"DEBUG": false
},
"string": "ooxx"
}
var definePluginOptionKey = define[process.env.NODE_ENV] ? process.env.NODE_ENV : define['default'] ? 'default' : '';
if(definePluginOptionKey){
var definePluginOption;
var defineContent = define[definePluginOptionKey];
if (typeof defineContent === 'object') {
for (var i in defineContent) {
(typeof(defineContent[i]) === 'string' || typeof(defineContent[i] === 'object')) && (defineContent[i] = JSON.stringify(defineContent[i]));
}
}
webpackConfig.plugins.push(
new webpack.DefinePlugin(defineContent)
)
} 那这样的好处是用户可以根据 诸如
等等. 或者之后直接集成到 |
可以考虑提一些配置到 webpackConfig 里,便于扩展。 |
目前给 目前我在覆盖上的解决方案是 http://ant-tool.github.io/spm-to-atool-build.html#spmautoprefixer 很麻烦 - -! 这边也同步一份 o.o |
在尝试把 atool-doc 生成的 修改 考虑这里也加一个开关么? |
@jaredleechn 现在的方案修改 |
想到加开关的方式
但这种恐怕加不完 这个 #114 挺不错的,我们把 |
开关是加不完的。。等 #114 吧。 |
补充下我现在 atool-doc 里面 hack 的做法 plugins 是直接覆盖,loader 遍历替换 |
注明: DefinePlugin 是一个可以被覆盖的插件 . 所以不需考虑先去除原有逻辑再重新 new |
之后需要考虑下如何把这些内置且无法修改参数的插件通过一种合理的方式让用户可以覆盖默认参数,或者传递参数.
DefinePlugin
现在在业务中有大量的需求.The text was updated successfully, but these errors were encountered: