[Vuejs]-How to add a path to webpack config?

1👍

This is how you should do:

  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
      'components': resolve('src/components'),
      'core': resolve('src/components/core'),
      'common': resolve('src/components/common'),
      'mixin': resolve('src/components/common/mixin'),
      'private': resolve('src/components/private'),
      'public': resolve('src/components/public'),
      'services': resolve('src/services')
    }
  }

Make sure your root folder is named src.

Then you can access directly from everywhere, for example:

import FormMixin from 'mixin/FormMixin'

1👍

in file webpack.base.conf.js change
components: path.resolve(__dirname, 'src/components') to components: resolve('src/components/component1')
and file App.vue change import Component1 from 'components/component' to import Component1 from 'components/component1'

👤Emma

Leave a comment