Skip to content

Commit

Permalink
Merge pull request #854 from OpenGeoscience/webpack-3
Browse files Browse the repository at this point in the history
Switch to webpack v3.
  • Loading branch information
manthey authored Jul 12, 2018
2 parents 91f4095 + 61f4c67 commit f4e8749
Show file tree
Hide file tree
Showing 8 changed files with 14,438 additions and 6,652 deletions.
42 changes: 35 additions & 7 deletions external.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
var path = require('path');
var webpack = require('webpack');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
/* webpack 4
mode: 'production',
*/
performance: {hints: false},
cache: true,
context: path.join(__dirname, 'src'),
entry: {
'geo.ext': './vendor.js',
Expand All @@ -18,18 +23,41 @@ module.exports = {
hammerjs: 'hammerjs/hammer.js'
}
},
/* webpack 3 */
plugins: [
new webpack.optimize.UglifyJsPlugin({
new UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
comments: /@(license|copyright)/
parallel: true,
uglifyOptions: {
compress: true,
comments: /@(license|copyright)/
},
sourceMap: true
})
],
/* end webpack 3 */
/* webpack 4
optimization: {
minimizer: [
new UglifyJsPlugin({
include: /\.min\.js$/,
parallel: true,
uglifyOptions: {
compress: true,
comments: /@(license|copyright)/
},
sourceMap: true
})
]
},
*/
module: {
loaders: [{
test: require.resolve('d3'), loader: 'expose?d3'
rules: [{
test: require.resolve('d3'),
use: ['expose-loader?d3']
}, {
test: require.resolve('hammerjs'), loader: 'expose?hammerjs'
test: require.resolve('hammerjs'),
use: ['expose-loader?hammerjs']
}]
}
};
30 changes: 26 additions & 4 deletions karma-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,24 @@ var FirefoxPrefs = {
};

module.exports = function (config) {
webpack_config.plugins.push(function () {
this.plugin('done', function (stats) {
if (stats.compilation.warnings.length) {
// Log each of the warnings
stats.compilation.warnings.forEach(function (warning) {
console.log(warning.message || warning);
});
// Pretend no assets were generated. This prevents the tests
// from running making it clear that there were warnings.
stats.stats = [{
toJson: function () {
return this;
},
assets: []
}];
}
});
});
var newConfig = {
autoWatch: false,
files: [
Expand Down Expand Up @@ -300,7 +318,7 @@ module.exports = function (config) {
'--kiosk',
'--incognito',
'--translate-script-url=""',
'--proxy-pac-url=' + config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac'
'--proxy-pac-url=' + config.protocol + '//' + (config.hostname || '127.0.0.1') + ':' + config.port + '/testdata/proxy-for-tests.pac'
])
},
FirefoxHeadlessTouch: {
Expand All @@ -315,7 +333,7 @@ module.exports = function (config) {
prefs: Object.assign({
// enable proxy
'network.proxy.type': 2,
'network.proxy.autoconfig_url': config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac',
'network.proxy.autoconfig_url': config.protocol + '//' + (config.hostname || '127.0.0.1') + ':' + config.port + '/testdata/proxy-for-tests.pac',
// enable touch
'dom.w3c_touch_events.enabled': 1
}, FirefoxPrefs)
Expand Down Expand Up @@ -347,13 +365,17 @@ module.exports = function (config) {
}
},
webpack: {
/* webpack 4
mode: 'production',
*/
performance: {hints: false},
cache: true,
devtool: 'inline-source-map',
module: {
loaders: webpack_config.module.loaders
rules: webpack_config.module.rules
},
resolve: webpack_config.resolve,
plugins: webpack_config.exposed_plugins
plugins: webpack_config.plugins
},
webpackMiddleware: {
stats: 'errors-only'
Expand Down
12 changes: 5 additions & 7 deletions karma-cov.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ module.exports = function (config) {
{type: 'text'}
]
};
karma_config.webpack.module.preLoaders = [
{
test: /\.js$/,
include: path.resolve('src/'),
loader: 'istanbul-instrumenter'
}
];
karma_config.webpack.module.rules.unshift({
test: /\.js$/,
include: path.resolve('src/'),
use: ['istanbul-instrumenter-loader']
});

config.set(karma_config);
};
Loading

0 comments on commit f4e8749

Please sign in to comment.