Idea或webstrom配置webpack设置路径alias实现代码自动补全功能

作开发的时候,每次import想要代码提示,经过../../src/components长长的相对路径用起来很不方便,经过配置webpack的alias就可让ide实现代码自动补全功能webpack

配置文件内容alias.config.js

const path = require('path');
module.exports = {
    resolve: {
        alias: {
            '@': path.resolve(__dirname, "src"),
            '_c': path.resolve(__dirname, "src/components"),
        }
    }
};

idea 配置

clipboard.png

这样就能很愉快的跑起来了

相关文章
相关标签/搜索