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