tn2000
tn2000

Reputation: 758

Vue.js - Configure a custom alias using WebPack

I am trying to create custom alias but I get an error:

Invalid options in vue.config.js: "resolve" is not allowed

This is what I did: enter image description here

Upvotes: 2

Views: 4120

Answers (1)

adnanmuttaleb
adnanmuttaleb

Reputation: 3604

vue.config.js is for vue configuration for webpack you need to wrap your resolve with either configureWebpack or chainWebpack, something like:

// vue.config.js
const path = require('path');
module.exports = {
  configureWebpack: {
    resolve: {...you config...}
  }
}

configureWebpack can be also a function, from the docs:

If you need conditional behavior based on the environment, or want to directly mutate the config, use a function (which will be lazy evaluated after the env variables are set). The function receives the resolved config as the argument. Inside the function, you can either mutate the config directly, OR return an object which will be merged:

Upvotes: 6

Related Questions