如何通过CLI运行webpack插件?我找到了类似的东西,但这不是我需要的。npx webpack plugin
如果你使用custom-webpack builder
将你的自定义webpack配置为一个函数,在构建时注入的参数是现有的webpack配置——也就是angular定义的那个。
一样:
webpack.config.js-(定义为角。json architect.buid.options.customWebpackConfig.path)
const merge = require('webpack-merge');
const YourCustomPlugin = require('./YourCustomPlugin');
// Config parameter is Angular default configurations.
module.exports = function(angularConfig) {
return merge(angularConfig, {
plugins: [new YourCustomPlugin()],
... // other custom webpack configuration
});
};
值得一提的是,还有另一个解决方案是ngx-build-plus
我是这么做的。我创建了另一个不依赖于webpack的文件,并将其作为常规js文件通过node cli运行