Skip to content

Commit 4223d33

Browse files
authored
Merge pull request #112 from Coding/hackape/resolve-alias
🔧 simplify alias configs in webpack
2 parents 55cfab7 + 5bea72c commit 4223d33

File tree

7 files changed

+22
-25
lines changed

7 files changed

+22
-25
lines changed

.eslintrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
"react/jsx-first-prop-new-line": 0
2525
},
2626
"settings": {
27-
"import/resolver": {
28-
"webpack": {
29-
"config": "webpack_configs/devServer.config.js"
30-
}
31-
}
27+
"import/resolver": "webpack"
3228
},
3329
"globals": {
3430
"i18n": false,

.flowconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
[ignore]
22
.*/node_modules/fbjs/.*
3+
4+
[options]
5+
module.system.node.resolve_dirname=node_modules
6+
module.system.node.resolve_dirname=app

app/commands/commandBindings/tab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow weak */
22
import { dispatch as $d } from '../../store'
3-
import store from 'app/mobxStore'
3+
import store from 'mobxStore'
44
import * as Tab from 'commons/Tab/actions'
55
import * as PaneActions from 'components/Pane/actions'
66

app/components/Editor/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { extendObservable, createTransformer, action } from 'mobx'
22
import { handleActions } from 'utils/actions'
33
import EditorTabState, { Tab, TabGroup } from './state'
4-
import store from 'app/mobxStore'
4+
import store from 'mobxStore'
55
import {
66
TAB_CREATE,
77
TAB_CREATE_IN_GROUP,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"enzyme-to-json": "^1.5.0",
4949
"eslint": "^3.15.0",
5050
"eslint-config-airbnb": "^14.1.0",
51-
"eslint-import-resolver-webpack": "^0.3.0",
51+
"eslint-import-resolver-webpack": "^0.8.1",
5252
"eslint-plugin-import": "^2.2.0",
5353
"eslint-plugin-jsx-a11y": "^4.0.0",
5454
"eslint-plugin-react": "^6.9.0",

webpack_configs/common.config.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const merge = require('webpack-merge')
88
const GitRevisionPlugin = require('git-revision-webpack-plugin')
99
const gitRevisionPlugin = new GitRevisionPlugin()
1010

11-
const rootDir = path.resolve(__dirname, '..')
11+
const PROJECT_ROOT = path.resolve(__dirname, '..')
1212

1313
module.exports = function (options={}) {
1414
const {
@@ -21,24 +21,18 @@ module.exports = function (options={}) {
2121
`${process.env.QINIU_SERVER}/` : path.join('/', staticDir, '/');
2222
return {
2323
entry: {
24-
main: [path.join(rootDir, 'app')],
25-
workspaces: [path.join(rootDir, 'app/workspaces_standalone')],
24+
main: [path.join(PROJECT_ROOT, 'app')],
25+
workspaces: [path.join(PROJECT_ROOT, 'app/workspaces_standalone')],
2626
vendor: ['babel-polyfill', 'react', 'react-dom', 'redux', 'react-redux'],
2727
},
2828
output: {
2929
publicPath,
30-
path: path.join(rootDir, 'build', staticDir),
30+
path: path.join(PROJECT_ROOT, 'build', staticDir),
3131
filename: '[name].[hash].js'
3232
},
3333
resolve: {
3434
extensions: ['*', '.js', '.jsx'],
35-
alias: {
36-
'app': path.join(rootDir, 'app'),
37-
'utils': path.join(rootDir, 'app/utils'),
38-
'config': path.join(rootDir, 'app/config.js'),
39-
'commons': path.join(rootDir, 'app/commons'),
40-
'components': path.join(rootDir, 'app/components'),
41-
}
35+
modules: ['node_modules', path.join(PROJECT_ROOT, 'app')],
4236
},
4337
resolveLoader: {
4438
modules: [ path.resolve(__dirname, "./loaders/"), "node_modules" ]
@@ -62,16 +56,16 @@ return {
6256
title: 'Coding WebIDE',
6357
excludeChunks: ['workspaces'],
6458
filename: (staticDir ? '../' : '') + mainEntryHtmlName,
65-
template: path.join(rootDir, 'app/index.html')
59+
template: path.join(PROJECT_ROOT, 'app/index.html')
6660
}),
6761
new HtmlWebpackPlugin({
6862
title: 'Coding WebIDE',
6963
excludeChunks: ['main'],
7064
filename: (staticDir ? '../' : '') + workspacesEntryHtmlName,
71-
template: path.join(rootDir, 'app/workspaces_standalone/index.html')
65+
template: path.join(PROJECT_ROOT, 'app/workspaces_standalone/index.html')
7266
}),
7367
new CopyWebpackPlugin([{
74-
from: path.join(rootDir, 'static/favicon.ico'),
68+
from: path.join(PROJECT_ROOT, 'static/favicon.ico'),
7569
to: (staticDir ? '../' : './'),
7670
}])
7771
],

yarn.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,18 +2276,21 @@ eslint-import-resolver-node@^0.2.0:
22762276
object-assign "^4.0.1"
22772277
resolve "^1.1.6"
22782278

2279-
eslint-import-resolver-webpack@^0.3.0:
2280-
version "0.3.2"
2281-
resolved "http://registry.npm.taobao.org/eslint-import-resolver-webpack/download/eslint-import-resolver-webpack-0.3.2.tgz#8b9b7279c1fe1d4fe10b2e0d2eec4e1780b3acb6"
2279+
eslint-import-resolver-webpack@^0.8.1:
2280+
version "0.8.1"
2281+
resolved "http://registry.npm.taobao.org/eslint-import-resolver-webpack/download/eslint-import-resolver-webpack-0.8.1.tgz#c7f8b4d5bd3c5b489457e5728c5db1c4ffbac9aa"
22822282
dependencies:
22832283
array-find "^1.0.0"
22842284
debug "^2.2.0"
22852285
enhanced-resolve "~0.9.0"
22862286
find-root "^0.1.1"
2287+
has "^1.0.1"
22872288
interpret "^1.0.0"
22882289
is-absolute "^0.2.3"
22892290
lodash.get "^3.7.0"
22902291
node-libs-browser "^1.0.0"
2292+
resolve "^1.2.0"
2293+
semver "^5.3.0"
22912294

22922295
eslint-module-utils@^2.0.0:
22932296
version "2.0.0"

0 commit comments

Comments
 (0)