-
Notifications
You must be signed in to change notification settings - Fork 233
Unable to use array of loaders in vue.config.js #124
Comments
Hi! The webpack-chain API mirrors the long-form loader webpack schema, and so requires that loaders be set individually rather than in an array: For example: config.module
.rule('po')
.test(/\.po$/)
.use('json')
.loader('json-loader')
.end()
.use('po')
.loader('po-loader')
// Any options could be set here
// .options(...)
.end() Corresponding webpack config output: {
test: /\.po$/,
use: [
/* config.module.rule('po').use('json') */
{
loader: 'json-loader'
},
/* config.module.rule('po').use('po') */
{
loader: 'po-loader',
// Any options would be set here
// options: { ... },
},
]
} If passed as an array there wouldn't be a way to specify which loader the We could perhaps add more validation so that Would you be up for opening a PR for either of those? :-) |
config.module
.rule('zepto')
.test(require.resolve('zepto'))
.use('exports')
.loader('exports-loader?window.Zepto')
.end()
.use('script')
.loader('script-loader')
.end() Thank you very much! |
Just a tip, if you are trying to overwrite the base loader in // vue.config.js
module.exports = {
chainWebpack: config => {
const svgRule = config.module.rule('svg')
// clear all existing loaders.
// if you don't do this, the loader below will be appended to
// existing loaders of the rule.
svgRule.uses.clear()
// add replacement loader(s)
svgRule
.use('vue-svg-loader')
.loader('vue-svg-loader')
}
} https://cli.vuejs.org/guide/webpack.html#replacing-loaders-of-a-rule |
Hi,
I have trouble to convert this webpack config to vue.config.js.
The
.po
file content is normally loaded by po-loader into JSON and then it's parsed by json-loader:I tried to use
chainWebpack
:but the result is (after running
vue inspect
)Which still results in the error:
Thank you for help!
The text was updated successfully, but these errors were encountered: