Open zjjjjjjjjjjd opened 5 years ago
@zjjjjjjjjjjd 求救,我新建了一个webpack.config.js,在里面配置了loader,但是提示
TypeError: customConfigFn is not a function
我的webpack.config.js代码如下
const config = {
module: {
rules: [
{
test: /\.css|less$/,
use: [
"style-loader",
{ loader: "css-loader", options: { importLoaders: 2 } },
"postcss-loader",
"less-loader",
],
},
],
},
};
module.exports = config;
我就想增加postcss-laoder。
getUserConfig ⬇️ getConfig ⬇️ applyWebpackConfig
大家可以参考下af-webpack获取webpackConfig的过程就明白了
Environment(required) | 环境(必填)
What did you do? Please provide steps to re-produce your problem.(请提供复现步骤)
在.webpackrc.js中后加入类似webpack.config.js的loader配置
webpackConfig.module.rules.unshift({ test: /\.jsx?$/, loader: 'es3ify-loader', });
What do you expected?(预期的正常效果)
提供一个可配置的字段如:
rules: [{test: /\.jsx?$/, loader: 'es3ify-loader'}]
What happen?(发生了何种非正常现象)
并没有这么一个字段
Re-producible online demo (可复现的在线demo)
无
场景说明
知道可以使用webpack.config.js来配置loader,但是webpack.config.js不支持babel的plugins 比如在webpack.config.js内写入
webpackConfig.babel.plugins.push('transform-runtime')
会提示找不到babel下的plugins, 所以切换到.webpackrc.js来配置,结果发现loader有配置不来,该如何解决?