Created
March 1, 2017 04:41
-
-
Save the-xs/9ee9383ded0109911c505549786f7030 to your computer and use it in GitHub Desktop.
code-splitting vs tree-shaking
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
import React from 'react'; | |
import ReactDom from 'react-dom'; | |
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; | |
import TextField from 'material-ui/TextField'; | |
const App = () => ( | |
<MuiThemeProvider> | |
<TextField hintText="my cool hint text" /> | |
</MuiThemeProvider> | |
); | |
ReactDom.render(<App />, document.body); |
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
{ | |
"name": "splitting-vs-shaking", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"dependencies": { | |
"material-ui": "^0.17.0", | |
"react": "^15.4.2", | |
"react-dom": "^15.4.2" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.23.1", | |
"babel-loader": "^6.3.2", | |
"babel-preset-es2015": "^6.22.0", | |
"babel-preset-react": "^6.23.0", | |
"html-webpack-plugin": "^2.28.0", | |
"webpack": "^2.2.1" | |
}, | |
"scripts": { | |
"build:splitting": "webpack --config webpack.splitting.js", | |
"build:bundle": "webpack --config webpack.bundle.js" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC" | |
} |
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
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
app: './src/index.js', | |
}, | |
output: { filename: 'bundle.js', path: 'dist-bundle' }, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
options: { | |
presets: [ | |
[ 'es2015', { modules: false } ], | |
'react', | |
] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ title: 'bundle' }), | |
], | |
} |
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
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
app: './src/index.js', | |
react: ['react', 'react-dom', 'material-ui'], | |
}, | |
output: { filename: '[name].js', path: 'dist-splitting' }, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
options: { | |
presets: [ | |
[ 'es2015', { modules: false } ], | |
'react', | |
] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ title: 'splitting' }), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'react' | |
}), | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment