From d636cbba6983cba0fb059ed2df786d0bf4d53ea7 Mon Sep 17 00:00:00 2001 From: Mirco Bertelli Date: Fri, 28 Aug 2015 17:11:42 +0200 Subject: [PATCH 1/2] Fixes #68, reduces boundle size to deploy --- package.json | 2 +- prod-webpack.config.js | 13 +++++++++++++ webpack.config.js | 12 +----------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 prod-webpack.config.js diff --git a/package.json b/package.json index 96e514d9dc..0c45aac67a 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "scripts": { "clean": "rm -Rf ./web/client/dist", - "compile": "npm run clean && mkdirp ./web/client/dist && webpack", + "compile": "npm run clean && mkdirp ./web/client/dist && webpack --config prod-webpack.config.js", "start": "webpack-dev-server --progress --colors --port 8081 --content-base web/client", "test": "karma start ./karma.conf.single-run.js", "continuoustest": "karma start ./karma.conf.continuous-test.js", diff --git a/prod-webpack.config.js b/prod-webpack.config.js new file mode 100644 index 0000000000..449db31cc9 --- /dev/null +++ b/prod-webpack.config.js @@ -0,0 +1,13 @@ +var webpackConfig = require('./webpack.config.js'); +var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin"); + +webpackConfig.plugins.push( + new UglifyJsPlugin({ + compress: {warnings: false}, + mangle: true + }) +); +webpackConfig.devtool = undefined; +webpackConfig.debug = false; + +module.exports = webpackConfig; diff --git a/webpack.config.js b/webpack.config.js index badb2914a1..7f24977d4c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,5 @@ var path = require("path"); var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); -var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin"); var rewriteUrl = function(replacePath) { return function(req, opt) { // gets called with request and proxy object var queryIndex = req.url.indexOf('?'); @@ -9,8 +8,6 @@ var rewriteUrl = function(replacePath) { }; }; -var PROD = JSON.parse(process.env.PROD_DEV || "0"); - module.exports = { entry: { viewer: path.join(__dirname, "web", "client", "examples", "viewer", "app"), @@ -21,13 +18,7 @@ module.exports = { publicPath: "/dist/", filename: "[name].js" }, - plugins: PROD ? [ - new CommonsChunkPlugin("commons", "mapstore-commons.js"), - new UglifyJsPlugin({ - compress: {warnings: false}, - mangle: true - }) - ] : [ + plugins: [ new CommonsChunkPlugin("commons", "mapstore-commons.js") ], resolve: { @@ -42,7 +33,6 @@ module.exports = { proxy: [{ path: new RegExp("/mapstore/rest/geostore/(.*)"), rewrite: rewriteUrl("/geostore/rest/$1"), - host: "mapstore.geo-solutions.it", target: "http://mapstore.geo-solutions.it" }] }, From cd5c75cb0d8c72b6ada14b548329e831d1467acd Mon Sep 17 00:00:00 2001 From: Mirco Bertelli Date: Fri, 28 Aug 2015 17:58:32 +0200 Subject: [PATCH 2/2] Fixes #68, adds missing host configuration for test proxy --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.config.js b/webpack.config.js index 7f24977d4c..b0fee37884 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -33,6 +33,7 @@ module.exports = { proxy: [{ path: new RegExp("/mapstore/rest/geostore/(.*)"), rewrite: rewriteUrl("/geostore/rest/$1"), + host: "mapstore.geo-solutions.it", target: "http://mapstore.geo-solutions.it" }] },