apersonw/taro-mall

解决WebStorm配置别名,无法单击进入的问题

apersonw opened this issue · 1 comments

**** 新建一个文件命名为webstorm.config.js存放到config目录即可
**** Preferences | Languages & Frameworks | JavaScript | Webpack选择webstorm.config.js

'use strict';
const path = require('path');

module.exports = {
  context: path.resolve(__dirname, './'),
  resolve: {
    extensions: ['.js', '.vue', '.json','.ts'],
    alias: {
      '@/assets': path.resolve(__dirname, '..', 'src/assets'),
      '@/components': path.resolve(__dirname, '..', 'src/components'),
      '@/containers': path.resolve(__dirname, '..', 'src/containers'),
      '@/utils': path.resolve(__dirname, '..', 'src/utils'),
      '@/package': path.resolve(__dirname, '..', 'package.json'),
      '@/project': path.resolve(__dirname, '..', 'project.config.json'),
    },
  },
};

如果是typescript,则需要配置tsconfig.json
增加以下配置
"paths": {"@/components/": ["./src/components/"]}