Created
December 24, 2017 18:15
-
-
Save sergeysova/be0c18ce5c119a90745962c48bd574da 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 { resolve } = require('path'); | |
| const { | |
| LoaderOptionsPlugin, | |
| EnvironmentPlugin, | |
| HotModuleReplacementPlugin, | |
| } = require('webpack'); | |
| const merge = require('webpack-merge'); | |
| const { config, loadersConfig, DIST } = require('./shared'); | |
| module.exports = merge(config, { | |
| profile: true, | |
| output: { | |
| filename: '[name].js', | |
| publicPath: '/', | |
| path: DIST, | |
| pathinfo: true, | |
| }, | |
| performance: { | |
| hints: false, | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.styl$/, | |
| use: [ | |
| { | |
| loader: 'style-loader', | |
| }, | |
| { | |
| loader: 'css-loader', | |
| options: loadersConfig.cssLoader, | |
| }, | |
| { | |
| loader: 'postcss-loader', | |
| }, | |
| { | |
| loader: 'stylus-loader', | |
| options: loadersConfig.stylusLoader, | |
| }, | |
| ], | |
| }, | |
| { | |
| test: /\.css$/, | |
| use: [ | |
| { loader: 'style-loader' }, | |
| { loader: 'css-loader' }, | |
| { loader: 'postcss-loader' }, | |
| ], | |
| }, | |
| ], | |
| }, | |
| plugins: [ | |
| new LoaderOptionsPlugin({ | |
| debug: true, | |
| minimize: false, | |
| }), | |
| new EnvironmentPlugin({ | |
| NODE_ENV: 'development', | |
| }), | |
| new HotModuleReplacementPlugin(), | |
| ], | |
| devServer: { | |
| contentBase: resolve(__dirname, '..', 'public'), | |
| // hot: true, | |
| noInfo: true, | |
| historyApiFallback: true, | |
| inline: false, | |
| stats: { | |
| colors: true, | |
| chunks: false, | |
| children: false, | |
| }, | |
| watchOptions: { | |
| aggregateTimeout: 300, | |
| poll: true, | |
| }, | |
| socket: resolve(__dirname, '..', 'webpack.sock'), | |
| }, | |
| }); | |
| module.exports.entry = { | |
| index: ['react-hot-loader/patch'].concat(config.entry.index), | |
| polyfill: ['react-hot-loader/patch'].concat(config.entry.polyfill), | |
| setLocale: config.entry.setLocale, | |
| }; |
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 { | |
| LoaderOptionsPlugin, | |
| EnvironmentPlugin, | |
| optimize: { | |
| ModuleConcatenationPlugin, | |
| UglifyJsPlugin, | |
| }, | |
| } = require('webpack'); | |
| const merge = require('webpack-merge'); | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| const { config, IS_DEV, loadersConfig } = require('./shared'); | |
| const extractCSS = new ExtractTextPlugin({ | |
| filename: IS_DEV ? '[name].css' : '[name]-[contenthash].css', | |
| allChunks: true, | |
| }); | |
| const extractSTYL = new ExtractTextPlugin({ | |
| filename: IS_DEV ? '[name].css' : '[name]-[contenthash].css', | |
| allChunks: true, | |
| }); | |
| module.exports = merge(config, { | |
| devtool: 'hidden-source-map', | |
| output: { | |
| filename: '[name].[chunkhash].js', | |
| publicPath: '/', | |
| crossOriginLoading: 'anonymous', | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.styl$/, | |
| use: extractSTYL.extract({ | |
| fallback: 'style-loader', | |
| use: [ | |
| { | |
| loader: 'css-loader', | |
| options: loadersConfig.cssLoader, | |
| }, | |
| { | |
| loader: 'postcss-loader', | |
| }, | |
| { | |
| loader: 'stylus-loader', | |
| options: loadersConfig.stylusLoader, | |
| }, | |
| ], | |
| }), | |
| }, | |
| { | |
| test: /\.css$/, | |
| use: extractCSS.extract({ | |
| fallback: 'style-loader', | |
| use: ['css-loader', 'postcss-loader'], | |
| }), | |
| }, | |
| ], | |
| }, | |
| plugins: [ | |
| extractCSS, | |
| extractSTYL, | |
| new LoaderOptionsPlugin({ | |
| debug: false, | |
| minimize: true, | |
| }), | |
| new EnvironmentPlugin({ | |
| NODE_ENV: 'production', | |
| }), | |
| new ModuleConcatenationPlugin(), | |
| new UglifyJsPlugin({ | |
| sourceMap: true, | |
| output: { | |
| comments: false, | |
| }, | |
| }), | |
| ], | |
| }); |
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 { resolve } = require('path'); | |
| const ENV = process.env.NODE_ENV || 'development'; | |
| // eslint-disable-next-line import/no-dynamic-require | |
| module.exports = require(resolve(__dirname, 'webpack', `${ENV}.config`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment