update frame-runner webpack config
This commit is contained in:
		
				
					committed by
					
						
						Mrugesh Mohapatra
					
				
			
			
				
	
			
			
			
						parent
						
							f500d565b2
						
					
				
				
					commit
					00cda68456
				
			@@ -56,7 +56,6 @@
 | 
			
		||||
    "reselect": "^3.0.1",
 | 
			
		||||
    "rxjs": "^5.5.7",
 | 
			
		||||
    "store": "^2.0.12",
 | 
			
		||||
    "uglifyjs-webpack-plugin": "^1.2.4",
 | 
			
		||||
    "validator": "^10.3.0",
 | 
			
		||||
    "webpack-remove-serviceworker-plugin": "^1.0.0"
 | 
			
		||||
  },
 | 
			
		||||
@@ -66,9 +65,9 @@
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "yarn build:frame-runner && gatsby build",
 | 
			
		||||
    "build:frame-runner": "webpack --config ./webpack-frame-runner.js",
 | 
			
		||||
    "build:loop-protect": "webpack --config ./webpack-loop-protect.js",
 | 
			
		||||
    "develop": "yarn build:frame-runner && gatsby develop",
 | 
			
		||||
    "build:frame-runner": "webpack --env.production --config ./webpack-frame-runner.js",
 | 
			
		||||
    "develop": "yarn develop:frame-runner && gatsby develop",
 | 
			
		||||
    "develop:frame-runner": "webpack --config ./webpack-frame-runner.js",
 | 
			
		||||
    "format": "yarn format:gatsby && yarn format:src && yarn format:utils && yarn lint",
 | 
			
		||||
    "format:gatsby": "prettier --write './gatsby*.js'",
 | 
			
		||||
    "format:src": "prettier --write './src/**/*.js'",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,72 +1,36 @@
 | 
			
		||||
const webpack = require('webpack');
 | 
			
		||||
const path = require('path');
 | 
			
		||||
const UglifyPlugin = require('uglifyjs-webpack-plugin');
 | 
			
		||||
 | 
			
		||||
const __DEV__ = process.env.NODE_ENV !== 'production';
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
module.exports = (env = {}) => {
 | 
			
		||||
  const __DEV__ = env.production !== true;
 | 
			
		||||
  return {
 | 
			
		||||
    mode: __DEV__ ? 'development' : 'production',
 | 
			
		||||
    entry: './src/client/frame-runner.js',
 | 
			
		||||
    devtool: __DEV__ ? 'inline-source-map' : 'source-map',
 | 
			
		||||
  node: {
 | 
			
		||||
    // Mock Node.js modules that Babel require()s but that we don't
 | 
			
		||||
    // particularly care about.
 | 
			
		||||
    fs: 'empty',
 | 
			
		||||
    module: 'empty',
 | 
			
		||||
    net: 'empty'
 | 
			
		||||
  },
 | 
			
		||||
    output: {
 | 
			
		||||
    filename: __DEV__ ? 'frame-runner.js' : 'frame-runner-[hash].js',
 | 
			
		||||
      filename: 'frame-runner.js',
 | 
			
		||||
      path: path.join(__dirname, './static/js')
 | 
			
		||||
    },
 | 
			
		||||
    stats: {
 | 
			
		||||
    // Examine all modules
 | 
			
		||||
    maxModules: Infinity,
 | 
			
		||||
      // Display bailout reasons
 | 
			
		||||
      optimizationBailout: true
 | 
			
		||||
    },
 | 
			
		||||
    module: {
 | 
			
		||||
      rules: [{
 | 
			
		||||
        test: /\.jsx?$/,
 | 
			
		||||
      include: [ path.join(__dirname, 'client/') ],
 | 
			
		||||
        include: [ path.join(__dirname, 'src/client/') ],
 | 
			
		||||
        use: {
 | 
			
		||||
          loader: 'babel-loader',
 | 
			
		||||
          options: {
 | 
			
		||||
            babelrc: false,
 | 
			
		||||
            presets: [
 | 
			
		||||
            [ 'es2015', { modules: false }],
 | 
			
		||||
            [ 'stage-3' ]
 | 
			
		||||
              [ '@babel/preset-env', { modules: false } ]
 | 
			
		||||
            ],
 | 
			
		||||
            plugins: [
 | 
			
		||||
            'transform-runtime',
 | 
			
		||||
            'lodash'
 | 
			
		||||
              '@babel/plugin-transform-runtime'
 | 
			
		||||
            ]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }]
 | 
			
		||||
  },
 | 
			
		||||
  externals: {
 | 
			
		||||
    rxjs: 'Rx'
 | 
			
		||||
  },
 | 
			
		||||
  plugins: [
 | 
			
		||||
    new webpack.DefinePlugin({
 | 
			
		||||
      'process.env': {
 | 
			
		||||
        NODE_ENV: JSON.stringify(__DEV__ ? 'development' : 'production')
 | 
			
		||||
      },
 | 
			
		||||
      __DEVTOOLS__: !__DEV__
 | 
			
		||||
    }),
 | 
			
		||||
    // Use browser version of visionmedia-debug
 | 
			
		||||
    new webpack.NormalModuleReplacementPlugin(
 | 
			
		||||
      /debug\/node/,
 | 
			
		||||
      'debug/src/browser'
 | 
			
		||||
    )
 | 
			
		||||
  ]
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports.plugins.push(
 | 
			
		||||
  new UglifyPlugin({
 | 
			
		||||
    test: /\.js($|\?)/i,
 | 
			
		||||
    cache: true,
 | 
			
		||||
    sourceMap: true
 | 
			
		||||
  })
 | 
			
		||||
);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user