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",
|
"reselect": "^3.0.1",
|
||||||
"rxjs": "^5.5.7",
|
"rxjs": "^5.5.7",
|
||||||
"store": "^2.0.12",
|
"store": "^2.0.12",
|
||||||
"uglifyjs-webpack-plugin": "^1.2.4",
|
|
||||||
"validator": "^10.3.0",
|
"validator": "^10.3.0",
|
||||||
"webpack-remove-serviceworker-plugin": "^1.0.0"
|
"webpack-remove-serviceworker-plugin": "^1.0.0"
|
||||||
},
|
},
|
||||||
@ -66,9 +65,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn build:frame-runner && gatsby build",
|
"build": "yarn build:frame-runner && gatsby build",
|
||||||
"build:frame-runner": "webpack --config ./webpack-frame-runner.js",
|
"build:frame-runner": "webpack --env.production --config ./webpack-frame-runner.js",
|
||||||
"build:loop-protect": "webpack --config ./webpack-loop-protect.js",
|
"develop": "yarn develop:frame-runner && gatsby develop",
|
||||||
"develop": "yarn build: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": "yarn format:gatsby && yarn format:src && yarn format:utils && yarn lint",
|
||||||
"format:gatsby": "prettier --write './gatsby*.js'",
|
"format:gatsby": "prettier --write './gatsby*.js'",
|
||||||
"format:src": "prettier --write './src/**/*.js'",
|
"format:src": "prettier --write './src/**/*.js'",
|
||||||
|
@ -1,72 +1,36 @@
|
|||||||
const webpack = require('webpack');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UglifyPlugin = require('uglifyjs-webpack-plugin');
|
|
||||||
|
|
||||||
const __DEV__ = process.env.NODE_ENV !== 'production';
|
module.exports = (env = {}) => {
|
||||||
|
const __DEV__ = env.production !== true;
|
||||||
module.exports = {
|
return {
|
||||||
mode: __DEV__ ? 'development' : 'production',
|
mode: __DEV__ ? 'development' : 'production',
|
||||||
entry: './src/client/frame-runner.js',
|
entry: './src/client/frame-runner.js',
|
||||||
devtool: __DEV__ ? 'inline-source-map' : 'source-map',
|
devtool: __DEV__ ? 'inline-source-map' : 'source-map',
|
||||||
node: {
|
output: {
|
||||||
// Mock Node.js modules that Babel require()s but that we don't
|
filename: 'frame-runner.js',
|
||||||
// particularly care about.
|
path: path.join(__dirname, './static/js')
|
||||||
fs: 'empty',
|
},
|
||||||
module: 'empty',
|
stats: {
|
||||||
net: 'empty'
|
// Display bailout reasons
|
||||||
},
|
optimizationBailout: true
|
||||||
output: {
|
},
|
||||||
filename: __DEV__ ? 'frame-runner.js' : 'frame-runner-[hash].js',
|
module: {
|
||||||
path: path.join(__dirname, './static/js')
|
rules: [{
|
||||||
},
|
test: /\.jsx?$/,
|
||||||
stats: {
|
include: [ path.join(__dirname, 'src/client/') ],
|
||||||
// Examine all modules
|
use: {
|
||||||
maxModules: Infinity,
|
loader: 'babel-loader',
|
||||||
// Display bailout reasons
|
options: {
|
||||||
optimizationBailout: true
|
babelrc: false,
|
||||||
},
|
presets: [
|
||||||
module: {
|
[ '@babel/preset-env', { modules: false } ]
|
||||||
rules: [{
|
],
|
||||||
test: /\.jsx?$/,
|
plugins: [
|
||||||
include: [ path.join(__dirname, 'client/') ],
|
'@babel/plugin-transform-runtime'
|
||||||
use: {
|
]
|
||||||
loader: 'babel-loader',
|
}
|
||||||
options: {
|
|
||||||
babelrc: false,
|
|
||||||
presets: [
|
|
||||||
[ 'es2015', { modules: false }],
|
|
||||||
[ 'stage-3' ]
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
'transform-runtime',
|
|
||||||
'lodash'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}]
|
||||||
}]
|
}
|
||||||
},
|
};
|
||||||
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