1. 程式人生 > >nuxt2.0 設定 webpack 路徑別名

nuxt2.0 設定 webpack 路徑別名

如果想在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') } }