Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Babel and Uglify config for the API build #4507

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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