12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- const webpack = require('webpack')
- const path = require('path')
- const isProduction = process.env.NODE_ENV === 'production'
-
- console.log('isProduction : ', isProduction)
-
- module.exports = {
- entry: isProduction
- ? './src/index.js'
- : ['babel-polyfill', './src/index.dev.js'],
- output: {
- path: path.resolve(__dirname, 'dist'),
- filename: isProduction ? 'html-document.app.js' : 'html-document.app.dev.js',
- pathinfo: !isProduction,
- library: isProduction ? 'appHtmlDocument' : undefined,
- libraryTarget: isProduction ? 'var' : undefined
- },
- externals: {},
-
-
-
-
-
-
-
-
- devServer: {
- contentBase: path.join(__dirname, 'dist/'),
- port: 8071,
- hot: true,
- noInfo: true,
- overlay: {
- warnings: false,
- errors: true
- },
- historyApiFallback: true
-
-
-
- },
- devtool: isProduction ? false : 'cheap-module-source-map',
- module: {
- rules: [{
- test: /\.jsx?$/,
- enforce: 'pre',
- use: 'standard-loader',
- exclude: [/node_modules/]
- }, {
- test: [/\.js$/, /\.jsx$/],
- loader: 'babel-loader',
- options: {
- presets: ['env', 'react'],
- plugins: ['transform-object-rest-spread', 'transform-class-properties', 'transform-object-assign']
- },
- exclude: [/node_modules/]
- }, {
- test: /\.css$/,
- use: ['style-loader', 'css-loader']
- }, {
- test: /\.styl$/,
- use: ['style-loader', 'css-loader', 'stylus-loader']
- }, {
- test: /\.(jpg|png|svg)$/,
- loader: 'url-loader',
- options: {
- limit: 25000
- }
- }]
- },
- resolve: {
- extensions: ['.js', '.jsx']
- },
- plugins: [
- ...[],
- ...(isProduction
- ? [
- new webpack.DefinePlugin({
- 'process.env': { 'NODE_ENV': JSON.stringify('production') }
- }),
- new webpack.optimize.UglifyJsPlugin({
- compress: { warnings: false }
- })
- ]
- : []
- )
- ]
- }
|