E
E
Eugene2019-03-02 23:32:44
webpack
Eugene, 2019-03-02 23:32:44

How to configure component path in VuePress via alias?

Hello. Need help. Maybe I'm doing something wrong, but I can't figure out what. I want to implement access to components through an alias in VuePress. It seems that I am doing everything as it should, but even does not want to work
Call line in the Layout.vue file

import Header from '@/components/base/Header/Header.vue'

Config:
const path = require('path')

module.exports = {
  title: 'Test',
  description: "Test using VuePress",
  module: {
    rules: [{
      test: /\.scss$/,
      use: [
          "style-loader", 
          "sass-loader", 
          {
            loader: 'css-loader',
            options: {
              modules: true,
              localIdentName: '[local]_[hash:base64:8]'
            }
          }
      ]
    }]
  },
  configureWebpack: {
    resolve: {
      alias: {
        "@": path.resolve(__dirname, 'src/')
      }
    },
  }
}


Mistake:
Error: Can't resolve '@/components/base/Header/Header.vue'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-03-03
@dragonesis

In general, the answer was found in the morning. Remove the slash from "src/", everything works, which seems to be logical) If it hadn't happened, Danil 's comment would have solved the issue.
PS
But yesterday it didn't work without the slash

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question