-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53cf881
commit 9f37afb
Showing
45 changed files
with
2,213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": [ | ||
["es2015", {"modules": false}], | ||
"stage-2", | ||
"react" | ||
], | ||
"plugins": [ | ||
"react-hot-loader/babel", | ||
["import", { "libraryName": "antd", "style": "css" }] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"extends": "airbnb", | ||
"ecmaFeatures": { | ||
"jsx": true, | ||
"modules": true, | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
}, | ||
"parser": "babel-eslint", | ||
"plugins": [ | ||
"react", | ||
"import", | ||
"jsx-a11y", | ||
], | ||
"rules": { | ||
// 缩进设置 | ||
"indent": ["error", 4], | ||
"react/jsx-indent": ["error", 4], | ||
// 设置jsx中属性的缩进 | ||
"react/jsx-indent-props": ["error", 4], | ||
// jsx语法中属性使用双引号 | ||
"jsx-quotes": ["error", "prefer-double"], | ||
// 设置换行符的类型 | ||
"linebreak-style": ["error", "unix"], | ||
"func-names": [2, "as-needed"], | ||
"quotes": [2, "single"], | ||
"strict": [2, "never"], | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2, | ||
// 设置非交互元素不能有鼠标 键盘事件 | ||
"jsx-a11y/no-static-element-interactions": "off", | ||
// 设置PropTypes不可设置的类型 | ||
"react/forbid-prop-types": ["error", { forbid: ["any"] }], | ||
// 设置过滤加载的包 | ||
"import/no-extraneous-dependencies": ["error", { devDependencies: ["*.js", "build/*.js"] }], | ||
// 设置阴影变量 | ||
"no-shadow": ["error", { "builtinGlobals": false, "hoist": "never", "allow": [] }], | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"webpack": { | ||
"config": "build/webpack.config.dev.js" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
npm-debug.log | ||
.DS_Store | ||
dist | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var path = require('path'); | ||
|
||
// 根路径 | ||
var ROOT_PATH = path.resolve(__dirname, '../'); | ||
|
||
// 源码路径 | ||
var SRC_PATH = path.resolve(ROOT_PATH, 'src'); | ||
|
||
// 产出路径 | ||
var DIST_PATH = path.resolve(ROOT_PATH, 'dist'); | ||
|
||
// 模块路径 | ||
var NODE_MODULES_PATH = path.resolve(ROOT_PATH, 'node_modules'); | ||
|
||
// 通用组件路径 | ||
var COMPONENT_PATH = path.resolve(SRC_PATH, 'components'); | ||
|
||
// 业务组件路径 | ||
var CONTAINERS_PATH = path.resolve(SRC_PATH, 'containers'); | ||
|
||
// actions路径 | ||
var ACTIONS_PATH = path.resolve(SRC_PATH, 'actions'); | ||
|
||
// reducers路径 | ||
var REDUCERS_PATH = path.resolve(SRC_PATH, 'reducers'); | ||
|
||
// constants路径 | ||
var CONSTANTS_PATH = path.resolve(SRC_PATH, 'constants'); | ||
|
||
// assets路径 | ||
var ASSETS_PATH = path.resolve(SRC_PATH, 'assets'); | ||
|
||
// html tpl 路径 | ||
var HTML_TPL_PATH = path.resolve(ROOT_PATH, 'index.html'); | ||
|
||
// 入口文件路径 | ||
var IndexPath = path.resolve(SRC_PATH, 'index.jsx'); | ||
|
||
// 图标路径 | ||
var faviconPath = path.resolve(ROOT_PATH, 'favicon.ico'); | ||
|
||
module.exports = { | ||
ROOT_PATH, | ||
SRC_PATH, | ||
DIST_PATH, | ||
NODE_MODULES_PATH, | ||
COMPONENT_PATH, | ||
CONTAINERS_PATH, | ||
ACTIONS_PATH, | ||
REDUCERS_PATH, | ||
CONSTANTS_PATH, | ||
ASSETS_PATH, | ||
HTML_TPL_PATH, | ||
IndexPath, | ||
faviconPath, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
var webpack = require('webpack'); | ||
var chalk = require('chalk'); | ||
var { | ||
ROOT_PATH, | ||
SRC_PATH, | ||
DIST_PATH, | ||
NODE_MODULES_PATH, | ||
COMPONENT_PATH, | ||
CONTAINERS_PATH, | ||
ACTIONS_PATH, | ||
REDUCERS_PATH, | ||
CONSTANTS_PATH, | ||
ASSETS_PATH, | ||
IndexPath, | ||
} = require('./path'); | ||
|
||
var port = 3001; | ||
|
||
console.log(chalk.green( | ||
` | ||
info: | ||
端口 ${port} | ||
开发配置 | ||
` | ||
)); | ||
|
||
module.exports = { | ||
context: ROOT_PATH, | ||
|
||
entry: [ | ||
'react-hot-loader/patch', | ||
|
||
`webpack-dev-server/client?http://localhost:${port}`, | ||
|
||
'webpack/hot/only-dev-server', | ||
|
||
IndexPath, | ||
], | ||
|
||
output: { | ||
filename: '[name].js', | ||
|
||
path: DIST_PATH, | ||
|
||
publicPath: '/public/', | ||
}, | ||
|
||
devtool: 'inline-source-map', | ||
|
||
module: { | ||
rules: [{ | ||
test: /\.jsx?$/, | ||
use: [ | ||
'babel-loader', | ||
], | ||
exclude: /node_modules/, | ||
}, { | ||
test: /\.css$/, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
], | ||
}, { | ||
test: /\.styl$/, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
"stylus-loader" | ||
], | ||
}, { | ||
test: /\.(gif|jpe?g|png)$/, | ||
include: SRC_PATH, | ||
use: [{ | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
}, | ||
}, ], | ||
}, { | ||
test: /\.(woff|woff2)$/, | ||
use: [{ | ||
loader: 'url-loader', | ||
options: { | ||
limit: 20000, | ||
}, | ||
}, ], | ||
}, { | ||
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, | ||
use: 'url-loader' | ||
}, { | ||
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, | ||
use: 'file-loader' | ||
}, { | ||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, | ||
use: 'url-loader' | ||
}, | ||
// { | ||
// test: /\.jsx?$/, | ||
// include: SRC_PATH, | ||
// enforce: 'pre', | ||
// use: [ | ||
// { | ||
// loader: 'eslint-loader', | ||
// options: { | ||
// emitWarning: true, | ||
// }, | ||
// }, | ||
// ], | ||
// } | ||
], | ||
}, | ||
|
||
resolve: { | ||
alias: { | ||
Components: COMPONENT_PATH, | ||
Containers: CONTAINERS_PATH, | ||
Actions: ACTIONS_PATH, | ||
Reducers: REDUCERS_PATH, | ||
Constants: CONSTANTS_PATH, | ||
Assets: ASSETS_PATH, | ||
}, | ||
extensions: [".js", ".json", ".jsx", ".css", ".scss", ], | ||
}, | ||
|
||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
// enable HMR globally | ||
|
||
new webpack.NamedModulesPlugin(), | ||
// prints more readable module names in the browser console on HMR updates | ||
|
||
new webpack.NoEmitOnErrorsPlugin(), | ||
// do not emit compiled assets that include errors | ||
], | ||
|
||
devServer: { | ||
port: port, | ||
host: '0.0.0.0', | ||
historyApiFallback: true, | ||
stats: { | ||
colors: true | ||
}, | ||
proxy: { | ||
'/api/*': { | ||
target: 'http://127.0.0.1:8888', | ||
secure: false, | ||
headers: { | ||
Host: '127.0.0.1' | ||
} | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.