Recently, when I used vue scaffolding to build a new project, I found that vue-CLI provided version 3.0.0-beta.6. After installation, I could not find config, build and other directories. I did not know where to configure alias

I looked at the official document and simplified it to use vue.config.js to configure the project. I found webpack all the way and found that it can use the call mode of Webpack-chain API to simplify the modification of Webpack configuration.

The installation

npm install -g @vue/cli
# or
yarn global add @vue/cli

vue create my-project
Copy the code

Start the

"scripts": {
    "serve": "vue-cli-service serve"."build": "vue-cli-service build"."lint": "vue-cli-service lint"
}
Copy the code

configuration

Create vue.config.js in the root directory

const path = require('path');
function resolve (dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    lintOnSave: true.chainWebpack: (config) = >{
        config.resolve.alias
            .set('@ $', resolve('src'))
            .set('assets',resolve('src/assets'))
            .set('components',resolve('src/components'))
            .set('layout',resolve('src/layout'))
            .set('base',resolve('src/base'))
            .set('static',resolve('src/static'))}}Copy the code

reference

vue-cli configuration

webpack-chain

Thank you for your reading. I hope we can discuss and learn together.