Last active
March 12, 2018 01:23
-
-
Save stevekinney/15cea80a69998f5c383754ad8e44eec1 to your computer and use it in GitHub Desktop.
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 path = require('path'); | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| module.exports = { | |
| mode: 'production', | |
| entry: { | |
| vendor: ['react', 'react-dom', 'redux', 'react-redux'], | |
| main: path.join(__dirname, '..', '/src/index.js'), | |
| }, | |
| output: { | |
| path: path.resolve(__dirname, '..', 'dist'), | |
| filename: '[name].[hash].bundle.js', | |
| publicPath: '/', | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.(eot|svg|ttf|woff|woff2)$/, | |
| loader: 'file-loader?name=[name].[ext]', | |
| }, | |
| { | |
| test: /\.jsx?$/, | |
| use: ['babel-loader'], | |
| exclude: /node_modules/, | |
| }, | |
| { | |
| test: /\.s?css$/, | |
| exclude: /node_modules/, | |
| use: ExtractTextPlugin.extract({ | |
| fallback: 'style-loader', | |
| use: [ | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| minimize: true, | |
| modules: true, | |
| importLoaders: true, | |
| localIdentName: '[name]__[local]--[hash:base64:5].css', | |
| sourcemaps: true, | |
| }, | |
| }, | |
| { | |
| loader: 'sass-loader', | |
| options: { | |
| sourcemaps: true, | |
| }, | |
| }, | |
| ], | |
| }), | |
| }, | |
| { | |
| test: /\.s?css$/, | |
| include: /node_modules/, | |
| use: ExtractTextPlugin.extract({ | |
| fallback: 'style-loader', | |
| use: [ | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| minimize: true, | |
| }, | |
| }, | |
| { | |
| loader: 'sass-loader', | |
| options: { | |
| sourcemaps: true, | |
| }, | |
| }, | |
| ], | |
| }), | |
| }, | |
| ], | |
| }, | |
| resolve: { | |
| extensions: ['.js', '.jsx'], | |
| }, | |
| plugins: [ | |
| new CopyWebpackPlugin([ | |
| { | |
| from: 'node_modules/monaco-editor/min/vs', | |
| to: 'vs', | |
| } | |
| ]), | |
| new CopyWebpackPlugin([{ from: 'public' }]), | |
| new webpack.DefinePlugin({ | |
| 'process.env.NODE_ENV': JSON.stringify('production'), | |
| }), | |
| new ExtractTextPlugin({ | |
| allChunks: true, | |
| filename: '[name].[hash].css', | |
| }), | |
| new HtmlWebpackPlugin({ template: './public/index.html' }), | |
| new BundleAnalyzerPlugin(), | |
| ], | |
| optimization: { | |
| splitChunks: { | |
| cacheGroups: { | |
| vendor: { | |
| test: /node_modules/, | |
| chunks: 'initial', | |
| name: 'vendor', | |
| enforce: true | |
| }, | |
| } | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment