nuxt2.0 设置 webpack 路径别名

版权声明:转载请评论留言 https://blog.csdn.net/solocao/article/details/83240074

如果想在nuxt中直接使用其他文件的路径,比如下面的components,我们需要在nuxt.config.js进行配置即可。

import SiteHeader from 'components/site/SiteHeader.vue'
 build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      // Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push()
      }
      config.resolve.alias['components'] = path.resolve(__dirname, 'components')
    }
  }

猜你喜欢

转载自blog.csdn.net/solocao/article/details/83240074