diff --git a/package.json b/package.json index ee334bf199c9a0e76da7c5a801df2139ea2cf8d6..2d21eb659874e88c3762ee38b8cc426177b3f6c1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "main": "index.js", "license": "MIT", "scripts": { - "start": "webpack-dev-server --hot --inline & python3 zesje" + "start": "webpack-dev-server --hot --inline --config webpack.dev.js & python3 zesje", + "build": "webpack --config webpack.prod.js" }, "dependencies": { "babel-plugin-syntax-dynamic-import": "^6.18.0", @@ -23,8 +24,10 @@ "react-router-dom": "^4.2.2", "react-table": "^6.7.6", "style-loader": "^0.19.1", + "uglifyjs-webpack-plugin": "^1.1.6", "url-loader": "^0.6.2", - "webpack": "^3.10.0" + "webpack": "^3.10.0", + "webpack-merge": "^4.1.1" }, "devDependencies": { "babel-core": "^6.26.0", diff --git a/webpack.config.js b/webpack.common.js similarity index 68% rename from webpack.config.js rename to webpack.common.js index da046c3fd81358df7495df458dd99f57a9cc9e06..56e9b812304ed23e099256b3d52cb1dd417e1e79 100644 --- a/webpack.config.js +++ b/webpack.common.js @@ -27,27 +27,5 @@ module.exports = { ] }, - plugins: [HtmlWebpackPluginConfig], - - devServer: { - hot: true, - inline: true, - proxy: { - '/api': { - target: 'http://localhost:5000' - } - }, - historyApiFallback: true, - port: 8881, - publicPath: '/', - host: '0.0.0.0', - overlay: { - warnings: true, - errors: true - }, - watchContentBase: true, - watchOptions: { - poll: true - } - } + plugins: [HtmlWebpackPluginConfig] } diff --git a/webpack.dev.js b/webpack.dev.js new file mode 100644 index 0000000000000000000000000000000000000000..2122de03c58ef97e05f4e019214fc3fc4a895365 --- /dev/null +++ b/webpack.dev.js @@ -0,0 +1,29 @@ +const merge = require('webpack-merge'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const common = require('./webpack.common.js'); + +module.exports = merge(common, { + devtool: 'eval-source-map', + + devServer: { + hot: true, + inline: true, + proxy: { + '/api': { + target: 'http://localhost:5000' + } + }, + historyApiFallback: true, + port: 8881, + publicPath: '/', + host: '0.0.0.0', + overlay: { + warnings: true, + errors: true + }, + watchContentBase: true, + watchOptions: { + poll: true + } + } +}) \ No newline at end of file diff --git a/webpack.prod.js b/webpack.prod.js new file mode 100644 index 0000000000000000000000000000000000000000..a380203565f6de59f42fba7566154e4913d403da --- /dev/null +++ b/webpack.prod.js @@ -0,0 +1,18 @@ +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const common = require('./webpack.common.js'); + +module.exports = merge(common, { + devtool: 'source-map', + plugins: [ + new UglifyJsPlugin({ + parallel: true, + cache: true, + sourceMap: true + }), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production') + }) + ] +}) \ No newline at end of file