Skip to content

Commit

Permalink
fix(build): add an argument for build prod when it is a Test CI. Adap…
Browse files Browse the repository at this point in the history
…t travis.yml to use it

ISSUES CLOSED: #572 #566
  • Loading branch information
ageorges-nbb committed Jul 31, 2018
1 parent 4231b9c commit b954903
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ script:
- npm run lint:all
- npm run test:ci:all
- npm run docs:coverage
- npm run build:showcase:ghpages
- if [[ $TRAVIS_TAG == "" && ${TRAVIS_EVENT_TYPE} != "cron" ]]; then npm run build:showcase:ghpages:ci-test-env; else npm run build:showcase:ghpages; fi
- npm run docs:publish
- npm run release:publish
- bash ./scripts/ci/print-logs.sh
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"build:stark-ui": "npm run build -- --packages=stark-ui",
"build:showcase": "cd showcase && npm run build:prod && cd ..",
"build:showcase:ghpages": "cd showcase && npm run build:prod:ghpages && cd ..",
"build:showcase:ghpages:ci-test-env": "cd showcase && npm run build:prod:ghpages:ci-test-env && cd ..",
"clean": "npx rimraf ./dist",
"clean:all": "npm run clean && npm run clean:stark-build && npm run clean:stark-core && npm run clean:stark-ui && npm run clean:stark-testing && npm run clean:starter && npm run clean:showcase",
"clean:stark-build": "cd packages/stark-build && npm run clean && cd ../..",
Expand Down
5 changes: 4 additions & 1 deletion packages/stark-build/config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ module.exports = options => {
? [
{
test: /\.js$/,
use: [buildOptimizerLoader]
use: [buildOptimizerLoader],
exclude: [
helpers.root("node_modules/prettier/parser-typescript.js")
]
}
]
: []),
Expand Down
20 changes: 13 additions & 7 deletions packages/stark-build/config/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const HashedModuleIdsPlugin = require("webpack/lib/HashedModuleIdsPlugin");

function getUglifyOptions(supportES2015) {
function getUglifyOptions(supportES2015, isCITestEnv = false) {
const uglifyCompressOptions = {
pure_getters: true /* buildOptimizer */,
// PURE comments work best with 3 passes.
// See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
passes: 3 /* buildOptimizer */
passes: isCITestEnv ? 1 : 3 /* buildOptimizer */
};

return {
Expand All @@ -54,9 +54,10 @@ module.exports = function() {
HMR: false,
environment: buildUtils.DEFAULT_METADATA.E2E ? "e2e.prod" : "prod"
});
const isCITestEnv = helpers.hasProcessFlag("ci-test-env");
const supportES2015 = buildUtils.supportES2015(METADATA.TS_CONFIG_PATH);

return webpackMerge(commonConfig({ ENV: ENV, metadata: METADATA }), {
const webpackConfig = webpackMerge(commonConfig({ ENV: ENV, metadata: METADATA }), {
/**
* Stats lets you precisely control what bundle information gets displayed
* reference: https://webpack.js.org/configuration/stats/
Expand All @@ -71,8 +72,6 @@ module.exports = function() {

mode: "production",

devtool: "source-map",

// reference: https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
optimization: {
removeAvailableModules: true,
Expand All @@ -97,8 +96,9 @@ module.exports = function() {
*/
new UglifyJsPlugin({
parallel: true, // use multi-process parallel running to improve the build speed (default concurrent processes: os.cpus().length - 1)
sourceMap: true, // useful to still be able to debug in production
uglifyOptions: getUglifyOptions(supportES2015)
sourceMap: !isCITestEnv, // useful to still be able to debug in production
uglifyOptions: getUglifyOptions(supportES2015),
cache: true
}),
// other options than Uglify: BabelifyMinifyWebpackPlugin or ClosureCompilerPlugin

Expand Down Expand Up @@ -333,4 +333,10 @@ module.exports = function() {
})
]
});

if (!isCITestEnv) {
webpackConfig.devtool = "source-map";
}

return webpackConfig;
};
2 changes: 2 additions & 0 deletions showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
},
"scripts": {
"build:aot:prod": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 npm run webpack -- --config node_modules/@nationalbankbelgium/stark-build/config/webpack.prod.js --progress --profile --bail",
"build:aot:prod:ci-test-env": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 npm run webpack -- --config node_modules/@nationalbankbelgium/stark-build/config/webpack.prod.js --progress --profile --bail --ci-test-env",
"build:aot": "npm run build:aot:prod",
"build:aot:dev": "cross-env BUILD_AOT=1 npm run build:dev",
"build:dev": "npm run clean:dist && npm run webpack -- --config node_modules/@nationalbankbelgium/stark-build/config/webpack.dev.js --progress --profile",
"build:dev:monitor": "npx mkdirp reports && npm run build:dev -- --env.monitor",
"build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .",
"build:prod": "npm run clean:dist && npm run build:aot:prod",
"build:prod:ghpages": "npm run clean:dist && node ./ghpages-adapt-angular-json.js && npm run build:aot:prod",
"build:prod:ghpages:ci-test-env": "npm run clean:dist && node ./ghpages-adapt-angular-json.js && npm run build:aot:prod:ci-test-env",
"build": "npm run build:dev",
"check-deps": "npx npm-check-u",
"ci:aot": "cross-env BUILD_E2E=1 npm run lint && npm run test && npm run build:aot && npm run e2e",
Expand Down

0 comments on commit b954903

Please sign in to comment.