From 1fff6207a28c64c1166fb5fc49a3397755fe8f11 Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Tue, 21 Feb 2017 15:47:20 +0100 Subject: [PATCH 1/2] Fixed #1490: upgraded webpack to version 2 --- karma.conf.continuous-test.js | 68 ++++++++++-- karma.conf.single-run.js | 75 +++++++++++-- package.json | 13 +-- prod-webpack.config.js | 17 +-- project/prod-webpack.config.js | 20 +++- project/static/karma.conf.continuous-test.js | 67 ++++++++++-- project/static/karma.conf.single-run.js | 78 +++++++++++--- project/webpack.config.js | 46 ++++---- .../__tests__/FeatureGrid-test.jsx | 3 +- .../featuregrid/stores/featuregridstore.js | 2 +- web/client/examples/layertree/config.json | 6 +- web/client/examples/plugins/app.jsx | 2 +- webpack.config.js | 101 ++++++++++++------ 13 files changed, 370 insertions(+), 128 deletions(-) diff --git a/karma.conf.continuous-test.js b/karma.conf.continuous-test.js index e81e708c3d..316b664266 100644 --- a/karma.conf.continuous-test.js +++ b/karma.conf.continuous-test.js @@ -41,21 +41,67 @@ module.exports = function karmaConfig(config) { webpack: { devtool: 'eval', module: { - loaders: [ - { test: /\.jsx?$/, exclude: /(ol\.js$|node_modules)/, loader: 'babel-loader', include: path.join(__dirname, "web", "client") }, - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, - { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, - { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, - { test: /\.(png|jpg|gif|svg)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'} // inline base64 URLs for <=8k images, direct URLs for the rest - ], - postLoaders: [ ] + rules: [ + { + test: /\.jsx?$/, + exclude: /(ol\.js$|node_modules)/, + use: [{ + loader: 'babel-loader' + }], + include: path.join(__dirname, "web", "client") + }, + { + test: /\.css$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }] + }, + { + test: /\.less$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }, { + loader: 'less-loader' + }] + }, + { + test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'url-loader', + options: { + mimetype: "application/font-woff" + } + }] + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'file-loader', + options: { + name: "[name].[ext]" + } + }] + }, + { + test: /\.(png|jpg|gif|svg)$/, + use: [{ + loader: 'url-loader', + options: { + name: "[path][name].[ext]", + limit: 8192 + } + }] // inline base64 URLs for <=8k images, direct URLs for the rest + } + ] }, resolve: { - extensions: ['', '.js', '.json', '.jsx'] + extensions: ['.js', '.json', '.jsx'] } }, - webpackServer: { noInfo: true } diff --git a/karma.conf.single-run.js b/karma.conf.single-run.js index aa7e1a8acd..4c33284bb6 100644 --- a/karma.conf.single-run.js +++ b/karma.conf.single-run.js @@ -41,24 +41,77 @@ module.exports = function karmaConfig(config) { webpack: { devtool: 'eval', module: { - preLoaders: [ + rules: [ { test: /\.jsx?$/, exclude: /(__tests__|node_modules|legacy|libs\\Cesium|libs\\html2canvas)\\|(__tests__|node_modules|legacy|libs\/Cesium|libs\/html2canvas)\/|webpack\.js|utils\/(openlayers|leaflet)/, - loader: 'babel-istanbul' + enforce: "pre", + use: [ + { + loader: 'babel-istanbul-loader' + } + ] + }, + { + test: /\.jsx?$/, + exclude: /(ol\.js$|node_modules)/, + use: [ + { + loader: 'babel-loader' + } + ], + include: path.join(__dirname, "web", "client") + }, + { + test: /\.css$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }] + }, + { + test: /\.less$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }, { + loader: 'less-loader' + }] + }, + { + test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'url-loader', + options: { + mimetype: "application/font-woff" + } + }] + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'file-loader', + options: { + name: "[name].[ext]" + } + }] + }, + { + test: /\.(png|jpg|gif|svg)$/, + use: [{ + loader: 'url-loader', + options: { + name: "[path][name].[ext]", + limit: 8192 + } + }] // inline base64 URLs for <=8k images, direct URLs for the rest } - ], - loaders: [ - { test: /\.jsx?$/, exclude: /(ol\.js$|node_modules)/, loader: 'babel-loader', include: path.join(__dirname, "web", "client") }, - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, - { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, - { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, - { test: /\.(png|jpg|gif|svg)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'} // inline base64 URLs for <=8k images, direct URLs for the rest ] }, resolve: { - extensions: ['', '.js', '.json', '.jsx'] + extensions: ['.js', '.json', '.jsx'] } }, diff --git a/package.json b/package.json index 1adb57739e..e868385524 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "eslint-plugin-react": "3.0.0", "exists-file": "1.0.2", "expect": "1.13.4", - "extract-text-webpack-plugin": "0.8.2", + "extract-text-webpack-plugin": "2.0.0-rc.3", "file-loader": "0.8.5", "html-webpack-plugin": "2.17.0", - "istanbul-instrumenter-loader": "0.1.3", + "istanbul-instrumenter-loader": "2.0.0", "karma": "0.12.37", "karma-chrome-launcher": "0.1.12", "karma-cli": "0.0.4", @@ -39,7 +39,7 @@ "karma-mocha": "0.1.10", "karma-mocha-reporter": "1.3.0", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "1.6.0", + "karma-webpack": "2.0.2", "less": "2.7.1", "less-loader": "2.2.3", "mkdirp": "0.5.1", @@ -65,9 +65,10 @@ "simple-git": "1.33.1", "style-loader": "0.12.4", "url-loader": "0.5.7", - "webpack": "1.12.15", + "webpack": "2.2.1", "webpack-bundle-size-analyzer": "2.0.2", - "webpack-dev-server": "1.14.1" + "webpack-dev-server": "2.4.1", + "webpack-parallel-uglify-plugin": "0.4.0" }, "//": "replace react-sortable-items with official on npm when 0.0.10 with remove_deprecated PR in included", "dependencies": { @@ -152,7 +153,7 @@ "scripts": { "postinstall": "node checkCesium.js && mkdirp ./web/client/libs/Cesium && download --extract --out ./web/client/libs/Cesium https://cesiumjs.org/releases/Cesium-1.17.zip || echo Cesium already installed", "clean": "rimraf ./web/client/dist", - "compile": "npm run clean && mkdirp ./web/client/dist && webpack --config prod-webpack.config.js", + "compile": "npm run clean && mkdirp ./web/client/dist && webpack --progress --config prod-webpack.config.js", "analyze": "npm run clean && mkdirp ./web/client/dist && webpack --json | webpack-bundle-size-analyzer", "start": "webpack-dev-server --progress --colors --port 8081 --hot --inline --content-base web/client", "examples": "webpack-dev-server --progress --colors --port 8081 --hot --inline --content-base web/client --config examples-webpack.config.js", diff --git a/prod-webpack.config.js b/prod-webpack.config.js index a837595460..5e238fd16e 100644 --- a/prod-webpack.config.js +++ b/prod-webpack.config.js @@ -1,6 +1,7 @@ var webpackConfig = require('./webpack.config.js'); var path = require("path"); -var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin"); +var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); +var ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin"); var DefinePlugin = require("webpack/lib/DefinePlugin"); var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); @@ -9,6 +10,9 @@ var assign = require('object-assign'); assign(webpackConfig.entry, require('./examples.js')); webpackConfig.plugins = [ + new LoaderOptionsPlugin({ + debug: false + }), new DefinePlugin({ "__DEVTOOLS__": false }), @@ -20,14 +24,15 @@ webpackConfig.plugins = [ new NormalModuleReplacementPlugin(/leaflet$/, path.join(__dirname, "web", "client", "libs", "leaflet")), new NormalModuleReplacementPlugin(/openlayers$/, path.join(__dirname, "web", "client", "libs", "openlayers")), new NormalModuleReplacementPlugin(/proj4$/, path.join(__dirname, "web", "client", "libs", "proj4")), - new UglifyJsPlugin({ - sourceMap: false, - compress: {warnings: false}, - mangle: true + new ParallelUglifyPlugin({ + uglifyJS: { + sourceMap: false, + compress: {warnings: false}, + mangle: true + } }) ]; webpackConfig.devtool = undefined; -webpackConfig.debug = false; // this is a workaround for this issue https://github.com/webpack/file-loader/issues/3 // use `__webpack_public_path__` in the index.html when fixed diff --git a/project/prod-webpack.config.js b/project/prod-webpack.config.js index 5a2db104b9..d0a93b815a 100644 --- a/project/prod-webpack.config.js +++ b/project/prod-webpack.config.js @@ -1,10 +1,18 @@ var webpackConfig = require('./webpack.config.js'); var path = require("path"); -var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin"); +var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); +var ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin"); var DefinePlugin = require("webpack/lib/DefinePlugin"); var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); +var assign = require('object-assign'); + +assign(webpackConfig.entry, require('./examples.js')); + webpackConfig.plugins = [ + new LoaderOptionsPlugin({ + debug: false + }), new DefinePlugin({ "__DEVTOOLS__": false }), @@ -17,13 +25,15 @@ webpackConfig.plugins = [ new NormalModuleReplacementPlugin(/openlayers$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "openlayers")), new NormalModuleReplacementPlugin(/cesium$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "cesium")), new NormalModuleReplacementPlugin(/proj4$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "proj4")), - new UglifyJsPlugin({ - compress: {warnings: false}, - mangle: true + new ParallelUglifyPlugin({ + uglifyJS: { + sourceMap: false, + compress: {warnings: false}, + mangle: true + } }) ]; webpackConfig.devtool = undefined; -webpackConfig.debug = false; // this is a workaround for this issue https://github.com/webpack/file-loader/issues/3 // use `__webpack_public_path__` in the index.html when fixed diff --git a/project/static/karma.conf.continuous-test.js b/project/static/karma.conf.continuous-test.js index 73f2f33276..2876121bf0 100644 --- a/project/static/karma.conf.continuous-test.js +++ b/project/static/karma.conf.continuous-test.js @@ -46,18 +46,65 @@ module.exports = function karmaConfig(config) { ], devtool: 'inline-source-map', module: { - loaders: [ - { test: /\.jsx?$/, exclude: /ol\.js$/, loader: 'babel-loader', include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] }, - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, - { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, - { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, - { test: /\.(png|jpg|gif|svg)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'} // inline base64 URLs for <=8k images, direct URLs for the rest - ], - postLoaders: [ ] + rules: [ + { + test: /\.jsx?$/, + exclude: /ol\.js$/, + use: [{ + loader: 'babel-loader'} + ], + include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] + }, + { + test: /\.css$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }] + }, + { + test: /\.less$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }, { + loader: 'less-loader' + }] + }, + { + test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'url-loader', + options: { + mimetype: "application/font-woff" + } + }] + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'file-loader', + options: { + name: "[name].[ext]" + } + }] + }, + { + test: /\.(png|jpg|gif|svg)$/, + use: [{ + loader: 'url-loader', + options: { + name: "[path][name].[ext]", + limit: 8192 + } + }] // inline base64 URLs for <=8k images, direct URLs for the rest + } + ] }, resolve: { - extensions: ['', '.js', '.json', '.jsx'] + extensions: ['.js', '.json', '.jsx'] } }, diff --git a/project/static/karma.conf.single-run.js b/project/static/karma.conf.single-run.js index bc5c570f71..f382fa9d44 100644 --- a/project/static/karma.conf.single-run.js +++ b/project/static/karma.conf.single-run.js @@ -46,24 +46,76 @@ module.exports = function karmaConfig(config) { ], devtool: 'inline-source-map', module: { - loaders: [ - { test: /\.jsx?$/, exclude: /ol\.js$/, loader: 'babel-loader', include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] }, - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, - { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, - { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, - { test: /\.(png|jpg|gif|svg)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'} // inline base64 URLs for <=8k images, direct URLs for the rest - ], - postLoaders: [ - { + rules: [ + { test: /\.jsx?$/, - exclude: /(__tests__|node_modules|legacy)\/|webpack\.js|utils\/(openlayers|leaflet)/, - loader: 'istanbul-instrumenter' + exclude: /(__tests__|node_modules|legacy|libs\\Cesium|libs\\html2canvas)\\|(__tests__|node_modules|legacy|libs\/Cesium|libs\/html2canvas)\/|webpack\.js|utils\/(openlayers|leaflet)/, + enforce: "pre", + use: [ + { + loader: 'babel-istanbul-loader' + } + ] + }, + { + test: /\.jsx?$/, + exclude: /ol\.js$/, + use: [ + { + loader: 'babel-loader' + } + ], + include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] }, + { + test: /\.css$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }] + }, + { + test: /\.less$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }, { + loader: 'less-loader' + }] + }, + { + test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'url-loader', + options: { + mimetype: "application/font-woff" + } + }] + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'file-loader', + options: { + name: "[name].[ext]" + } + }] + }, + { + test: /\.(png|jpg|gif|svg)$/, + use: [{ + loader: 'url-loader', + options: { + name: "[path][name].[ext]", + limit: 8192 + } + }] // inline base64 URLs for <=8k images, direct URLs for the rest } ] }, resolve: { - extensions: ['', '.js', '.json', '.jsx'] + extensions: ['.js', '.json', '.jsx'] } }, diff --git a/project/webpack.config.js b/project/webpack.config.js index 4fd0fb2dc3..2e8ac78c05 100644 --- a/project/webpack.config.js +++ b/project/webpack.config.js @@ -1,15 +1,8 @@ var path = require("path"); var DefinePlugin = require("webpack/lib/DefinePlugin"); +var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); -var NoErrorsPlugin = require("webpack/lib/NoErrorsPlugin"); - -var rewriteUrl = function(replacePath) { - return function(req, opt) { // gets called with request and proxy object - var queryIndex = req.url.indexOf('?'); - var query = queryIndex >= 0 ? req.url.substr(queryIndex) : ""; - req.url = req.path.replace(opt.path, replacePath) + query; - }; -}; +var NoEmitOnErrorsPlugin = require("webpack/lib/NoEmitOnErrorsPlugin"); module.exports = { entry: { @@ -23,6 +16,9 @@ module.exports = { filename: "[name].js" }, plugins: [ + new LoaderOptionsPlugin({ + debug: true + }), new DefinePlugin({ "__DEVTOOLS__": true }), @@ -30,22 +26,22 @@ module.exports = { new NormalModuleReplacementPlugin(/openlayers$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "openlayers")), new NormalModuleReplacementPlugin(/cesium$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "cesium")), new NormalModuleReplacementPlugin(/proj4$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "proj4")), - new NoErrorsPlugin() + new NoEmitOnErrorsPlugin() ], resolve: { - extensions: ["", ".js", ".jsx"] + extensions: [".js", ".jsx"] }, module: { loaders: [ - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, + { test: /\.css$/, loader: 'style-loader!css-loader'}, + { test: /\.less$/, loader: "style-loader!css-loader!less-loader" }, { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, { test: /\.(png|jpg|gif)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'}, // inline base64 URLs for <=8k images, direct URLs for the rest { test: /\.jsx?$/, exclude: /(ol\.js)$|(Cesium\.js)$|(cesium\.js)$/, - loader: "react-hot", + loader: "react-hot-loader", include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")] }, { test: /\.jsx?$/, @@ -56,19 +52,15 @@ module.exports = { ] }, devServer: { - proxy: [{ - path: new RegExp("/mapstore/rest/geostore/(.*)"), - rewrite: rewriteUrl("/geostore/rest/$1"), - host: "mapstore.geo-solutions.it", - target: "http://mapstore.geo-solutions.it" - }, { - path: new RegExp("/mapstore/proxy(.*)"), - rewrite: rewriteUrl("/http_proxy/proxy$1"), - host: "localhost", - target: "http://localhost:8080" - }] + proxy: { + '/mapstore/rest/geostore': { + target: "http://dev.mapstore2.geo-solutions.it" + }, + '/mapstore/proxy': { + target: "http://dev.mapstore2.geo-solutions.it" + } + } }, - devtool: 'inline-source-map', - debug: true + devtool: 'eval' }; diff --git a/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx b/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx index 34abd4ebc2..09ce46f72a 100644 --- a/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx +++ b/web/client/components/data/featuregrid/__tests__/FeatureGrid-test.jsx @@ -9,7 +9,7 @@ const React = require("react"); const expect = require('expect'); const ReactDOM = require('react-dom'); const FeatureGrid = require('../FeatureGrid'); -const data = require("json!../../../../test-resources/featureGrid-test-data.json"); +const data = require("json-loader!../../../../test-resources/featureGrid-test-data.json"); const columnDef = [ {headerName: "Name", field: "properties.NAME_STATE", width: 150, pinned: true} @@ -79,4 +79,3 @@ describe("Test FeatureGrid Component", () => { expect(spy).toHaveBeenCalledWith(params.data); }); }); - diff --git a/web/client/examples/featuregrid/stores/featuregridstore.js b/web/client/examples/featuregrid/stores/featuregridstore.js index 2df3561350..ee12401b53 100644 --- a/web/client/examples/featuregrid/stores/featuregridstore.js +++ b/web/client/examples/featuregrid/stores/featuregridstore.js @@ -9,7 +9,7 @@ var DebugUtils = require('../../../utils/DebugUtils'); const {combineReducers} = require('redux'); -const exampleData = require('json!../../../test-resources/featureGrid-test-data.json'); +const exampleData = require('json-loader!../../../test-resources/featureGrid-test-data.json'); // reducers const reducers = combineReducers({ diff --git a/web/client/examples/layertree/config.json b/web/client/examples/layertree/config.json index 7edac76854..9cad0171b1 100644 --- a/web/client/examples/layertree/config.json +++ b/web/client/examples/layertree/config.json @@ -1,5 +1,5 @@ -module.exports = { - sources: { +{ + "sources": { "google": { "projection": "EPSG:900913", "ptype": "gxp_googlesource" @@ -26,7 +26,7 @@ module.exports = { "url": "http://tms.comune.fi.it/tiles/service/wms?SERVICE=WMS&REQUEST=GetCapabilities" } }, - layers: [ + "layers": [ { "selected": false, "title": "Open Street Map", diff --git a/web/client/examples/plugins/app.jsx b/web/client/examples/plugins/app.jsx index 4bf9a905b9..53a14a4b05 100644 --- a/web/client/examples/plugins/app.jsx +++ b/web/client/examples/plugins/app.jsx @@ -43,7 +43,7 @@ const startApp = () => { const Debug = require('../../components/development/Debug'); const assign = require('object-assign'); - const codeSample = require("raw!./sample.js.raw"); + const codeSample = require("raw-loader!./sample.js.raw"); let customReducers; diff --git a/webpack.config.js b/webpack.config.js index ea2f7f60ef..aa71fc6ab0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,15 +1,8 @@ var path = require("path"); var DefinePlugin = require("webpack/lib/DefinePlugin"); +var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); -var NoErrorsPlugin = require("webpack/lib/NoErrorsPlugin"); - -var rewriteUrl = function(replacePath) { - return function(req, opt) { // gets called with request and proxy object - var queryIndex = req.url.indexOf('?'); - var query = queryIndex >= 0 ? req.url.substr(queryIndex) : ""; - req.url = req.path.replace(opt.path, replacePath) + query; - }; -}; +var NoEmitOnErrorsPlugin = require("webpack/lib/NoEmitOnErrorsPlugin"); module.exports = { entry: { @@ -23,6 +16,9 @@ module.exports = { filename: "[name].js" }, plugins: [ + new LoaderOptionsPlugin({ + debug: true + }), new DefinePlugin({ "__DEVTOOLS__": true, "__API_KEY_MAPQUEST__": JSON.stringify(process.env.__API_KEY_MAPQUEST__ || '') @@ -31,46 +27,87 @@ module.exports = { new NormalModuleReplacementPlugin(/cesium$/, path.join(__dirname, "web", "client", "libs", "cesium")), new NormalModuleReplacementPlugin(/openlayers$/, path.join(__dirname, "web", "client", "libs", "openlayers")), new NormalModuleReplacementPlugin(/proj4$/, path.join(__dirname, "web", "client", "libs", "proj4")), - new NoErrorsPlugin() + new NoEmitOnErrorsPlugin() ], resolve: { - extensions: ["", ".js", ".jsx"] + extensions: [".js", ".jsx"] }, module: { noParse: [/html2canvas/], - loaders: [ - { test: /\.css$/, loader: 'style!css'}, - { test: /\.less$/, loader: "style!css!less-loader" }, - { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, - { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" }, - { test: /\.(png|jpg|gif)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'}, // inline base64 URLs for <=8k images, direct URLs for the rest + rules: [ + { + test: /\.css$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }] + }, + { + test: /\.less$/, + use: [{ + loader: 'style-loader' + }, { + loader: 'css-loader' + }, { + loader: 'less-loader' + }] + }, + { + test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'url-loader', + options: { + mimetype: "application/font-woff" + } + }] + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, + use: [{ + loader: 'file-loader', + options: { + name: "[name].[ext]" + } + }] + }, + { + test: /\.(png|jpg|gif)$/, + use: [{ + loader: 'url-loader', + options: { + name: "[path][name].[ext]", + limit: 8192 + } + }] // inline base64 URLs for <=8k images, direct URLs for the rest + }, { test: /\.jsx$/, exclude: /(ol\.js)$|(Cesium\.js)$/, - loader: "react-hot", + use: [{ + loader: "react-hot-loader" + }], include: path.join(__dirname, "web", "client") }, { test: /\.jsx?$/, exclude: /(ol\.js)$|(Cesium\.js)$/, - loader: "babel-loader", + use: [{ + loader: "babel-loader" + }], include: path.join(__dirname, "web", "client") } ] }, devServer: { - proxy: [{ - path: new RegExp("/mapstore/rest/geostore/(.*)"), - rewrite: rewriteUrl("/mapstore/rest/geostore/$1"), - host: "dev.mapstore2.geo-solutions.it", - target: "http://dev.mapstore2.geo-solutions.it" - }, { - path: new RegExp("/mapstore/proxy(.*)"), - rewrite: rewriteUrl("/mapstore/proxy$1"), - host: "dev.mapstore2.geo-solutions.it", - target: "http://dev.mapstore2.geo-solutions.it" - }] + proxy: { + '/mapstore/rest/geostore': { + target: "http://dev.mapstore2.geo-solutions.it" + }, + '/mapstore/proxy': { + target: "http://dev.mapstore2.geo-solutions.it" + } + } }, - devtool: 'eval', - debug: true + devtool: 'eval' }; From 3c324f35c13466c224c54cd3ef77179b57779f0b Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Tue, 21 Feb 2017 16:25:39 +0100 Subject: [PATCH 2/2] Upgraded Karma to 1.5.0 --- package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e868385524..2378e9c490 100644 --- a/package.json +++ b/package.json @@ -28,16 +28,16 @@ "file-loader": "0.8.5", "html-webpack-plugin": "2.17.0", "istanbul-instrumenter-loader": "2.0.0", - "karma": "0.12.37", - "karma-chrome-launcher": "0.1.12", - "karma-cli": "0.0.4", - "karma-coverage": "0.4.2", + "karma": "1.5.0", + "karma-chrome-launcher": "2.0.0", + "karma-cli": "1.0.1", + "karma-coverage": "1.1.1", "karma-coveralls": "1.1.2", - "karma-firefox-launcher": "0.1.7", - "karma-ie-launcher": "0.2.0", - "karma-junit-reporter": "0.3.8", - "karma-mocha": "0.1.10", - "karma-mocha-reporter": "1.3.0", + "karma-firefox-launcher": "1.0.0", + "karma-ie-launcher": "1.0.0", + "karma-junit-reporter": "1.2.0", + "karma-mocha": "1.3.0", + "karma-mocha-reporter": "2.2.2", "karma-sourcemap-loader": "0.3.7", "karma-webpack": "2.0.2", "less": "2.7.1",