Created
April 6, 2016 13:59
-
-
Save SoarLin/cb6b6657ae637549671a5632b6b425e8 to your computer and use it in GitHub Desktop.
webpack設定檔.md
This file contains hidden or 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
# Webpack 目前設定檔 | |
[TOC] | |
## 套件安裝 | |
* 主要套件 : `webpack` | |
* ESLint 檢查: `eslint eslint-loader eslint-plugin-react` | |
* Babel (ECMAScript6 語法轉換) : `babel-core babel-loader babel-preset-es2015` | |
* React 相關套件: `react rect-dom jsx-loader babel-preset-react` | |
```javascript | |
packages.json | |
{ | |
"name": "sample", | |
"version": "1.0.0", | |
"description": "", | |
"main": "webpack.config.js", | |
"dependencies": { | |
"jsx-loader": "^0.13.2", | |
"webpack": "^1.12.14" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.7.4", | |
"babel-loader": "^6.2.4", | |
"babel-preset-es2015": "^6.6.0", | |
"babel-preset-react": "^6.5.0", | |
"eslint": "^2.7.0", | |
"eslint-loader": "^1.3.0", | |
"eslint-plugin-react": "^4.2.3", | |
"react": "^0.14.8", | |
"react-dom": "^0.14.8" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} | |
``` | |
## webpack.config.js 設定檔 | |
* 目前就只測試到基本的 eslint 檢查,可用 .jsx 副檔名 | |
```javascript | |
webpack.config.js | |
module.exports = { | |
entry: ['./assets/jsx/app'], | |
output: { | |
path: 'public/js/', | |
filename: 'bundle.js' | |
}, | |
resolve: { | |
extensions: ['', '.js', '.jsx'] | |
}, | |
module: { | |
preLoaders: [ | |
{ | |
test: /\.jsx$/, | |
exclude: /node_modules/, | |
loader: 'eslint-loader' | |
} | |
], | |
loaders: [ | |
{ | |
test: /\.js|jsx$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
query:{ | |
"presets": ["es2015", "react"] | |
} | |
} | |
] | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment