Skip to content

Commit

Permalink
Fixed #1490: upgraded webpack to version 2 (#1491)
Browse files Browse the repository at this point in the history
* Fixed #1490: upgraded webpack to version 2

* Upgraded Karma to 1.5.0
  • Loading branch information
mbarto authored Feb 21, 2017
1 parent a84c0e1 commit ff04767
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 137 deletions.
68 changes: 57 additions & 11 deletions karma.conf.continuous-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
75 changes: 64 additions & 11 deletions karma.conf.single-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
},

Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@
"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",
"karma": "0.12.37",
"karma-chrome-launcher": "0.1.12",
"karma-cli": "0.0.4",
"karma-coverage": "0.4.2",
"istanbul-instrumenter-loader": "2.0.0",
"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": "1.6.0",
"karma-webpack": "2.0.2",
"less": "2.7.1",
"less-loader": "2.2.3",
"mkdirp": "0.5.1",
Expand All @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
17 changes: 11 additions & 6 deletions prod-webpack.config.js
Original file line number Diff line number Diff line change
@@ -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");

Expand All @@ -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
}),
Expand All @@ -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
Expand Down
20 changes: 15 additions & 5 deletions project/prod-webpack.config.js
Original file line number Diff line number Diff line change
@@ -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
}),
Expand All @@ -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
Expand Down
67 changes: 57 additions & 10 deletions project/static/karma.conf.continuous-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
},

Expand Down
Loading

0 comments on commit ff04767

Please sign in to comment.