Skip to content

Commit c0efbe0

Browse files
committed
chore: optimize alias
1 parent 694f9d3 commit c0efbe0

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

Diff for: config/webpack/webpack.base.config.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ module.exports = {
113113
],
114114
resolve: {
115115
alias: {
116-
actions: path.join(__dirname, '../../src/redux/actions'),
117-
api: path.join(__dirname, '../../src/api'),
118-
components: path.join(__dirname, '../../components'),
119-
histories: path.join(__dirname, '../../tools/history'),
120-
pConfig: path.join(__dirname, '../../config/project'),
121-
src: path.join(__dirname, '../../src'),
122-
tools: path.join(__dirname, '../../tools')
116+
'@/actions': path.join(__dirname, '../../src/redux/actions'),
117+
'@/api': path.join(__dirname, '../../src/api'),
118+
'@/components': path.join(__dirname, '../../components'),
119+
'@/histories': path.join(__dirname, '../../tools/history'),
120+
'@/pConfig': path.join(__dirname, '../../config/project'),
121+
'@/src': path.join(__dirname, '../../src'),
122+
'@/tools': path.join(__dirname, '../../tools')
123123
},
124124
extensions: ['.js', '.jsx', '.json']
125125
}

Diff for: jsconfig.json

+8-11
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
"target": "es6",
44
"baseUrl": ".",
55
"paths": {
6-
"actions": ["./src/redux/actions/index.js"],
7-
"api": ["./src/api/index.js"],
8-
"components": ["./components/"],
9-
"histories": ["./tools/history.js"],
10-
"pConfig": ["./config/project/index.js"],
11-
"src": ["./src/"],
12-
"tools": ["./tools/"]
6+
"@/actions": ["./src/redux/actions/index.js"],
7+
"@/api": ["./src/api/index.js"],
8+
"@/components": ["./components/"],
9+
"@/histories": ["./tools/history.js"],
10+
"@/pConfig": ["./config/project/index.js"],
11+
"@/src": ["./src/"],
12+
"@/tools": ["./tools/"]
1313
}
1414
},
15-
"exclude": [
16-
"node_modules",
17-
"dist"
18-
]
15+
"exclude": ["node_modules", "dist"]
1916
}

Diff for: src/api/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import httpServer from 'tools/http-server';
2-
import pConfig from 'pConfig';
1+
import httpServer from '@/tools/http-server';
2+
import pConfig from '@/pConfig';
33

44
import demo from './demo';
55

Diff for: src/pages/index/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { connect } from 'react-redux';
33

4-
import Api from 'api';
5-
import Actions from 'actions';
4+
import Api from '@/api';
5+
import Actions from '@/actions';
66
import s from './index.scss';
77

88
class IndexPage extends React.Component {

Diff for: src/router/index.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import React from 'react';
22
import { Router, Route, Redirect, Switch } from 'react-router-dom';
33
import Loadable from 'react-loadable';
44

5-
import history from 'histories';
5+
import history from '@/histories';
66
import routers from './routers';
7-
import ChunkLoading from 'components/chunk-loading';
7+
import ChunkLoading from '@/components/chunk-loading';
88

9-
let Routers = routers.map(route => {
9+
const Routers = routers.map(route => {
1010
return (
1111
<Route
1212
exact

0 commit comments

Comments
 (0)