Skip to content

Commit

Permalink
Merge pull request #4507 from camptocamp/api_babel
Browse files Browse the repository at this point in the history
Fix Babel and Uglify config for the API build
  • Loading branch information
fredj committed Jan 8, 2019
2 parents 20e5cca + 2420e9a commit 759e041
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions buildtools/webpack.api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

const dest = path.resolve(__dirname, '../api/dist/');

const babelPresetEnv = ['@babel/preset-env', {
targets: {
browsers: ['last 2 versions', 'Firefox ESR', 'ie 11'],
},
modules: false,
loose: true
}];

module.exports = (env, argv) => {
const library = argv.library ? argv.library : 'demo';
return {
Expand All @@ -11,11 +20,12 @@ module.exports = (env, argv) => {
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [require.resolve('@babel/preset-env')]
babelrc: false,
comments: false,
presets: [babelPresetEnv]
}
}
}]
Expand All @@ -28,6 +38,17 @@ module.exports = (env, argv) => {
libraryExport: 'default',
library: library
},
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
sourceMap: true,
uglifyOptions: {
compress: false
}
})
]
},
plugins: [
new CopyWebpackPlugin([{
from: './api/src/api.css',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build-ngeo-examples": "TARGET=ngeo-examples webpack --mode development --progress --debug",
"build-gmf-examples": "TARGET=gmf-examples webpack --mode development --progress --debug",
"build-gmf-apps": "TARGET=gmf-apps webpack --mode development --progress --debug",
"build-api": "webpack --config buildtools/webpack.api.js --mode development --library demo",
"build-api": "webpack --config buildtools/webpack.api.js --mode development --progress --debug",
"serve-ngeo-examples": "DEV_SERVER=1 TARGET=ngeo-examples webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --mode development --progress --watch --bail --debug",
"serve-gmf-examples": "DEV_SERVER=1 TARGET=gmf-examples webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --mode development --progress --watch --bail --debug",
"serve-gmf-apps": "DEV_SERVER=1 TARGET=gmf-apps webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --mode development --progress --watch --bail --debug",
Expand Down

0 comments on commit 759e041

Please sign in to comment.