Skip to content

Commit

Permalink
Dev/prod pl node compile, js maps for production (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
illepic authored Aug 23, 2019
1 parent 13d4bfa commit aa1a0bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
23 changes: 15 additions & 8 deletions apps/node-pl/pl-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ const pl = core(config);
const { cleanPublic } = config;
const { NODE_ENV } = process.env;

// Start/stop message template
const message = `Pattern Lab Node v${pl.version()} ${NODE_ENV} compile`;
// Shared options between dev/prod
const options = {
cleanPublic,
data: {
env: NODE_ENV || 'production',
},
};

/**
* Register pre-compile event
*/
pl.events.on('patternlab-build-start', () => console.log(`${message} START!`));
pl.events.on('patternlab-build-end', () => console.log(`${message} END!`));

/**
* Build PL patterns only
* patternsOnly in dev, full build in prod
*/
pl.patternsonly({
cleanPublic,
// Custom vars injected into PL global data
data: {
env: NODE_ENV || 'production',
},
}).then(() => console.log(`${message} END!`));
if (NODE_ENV === 'development') {
pl.patternsonly(options);
} else {
pl.build(options);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"setup": "patternlab install --config ./apps/node-pl/patternlab-config.json && patternlab build --config ./apps/node-pl/patternlab-config.json",
"export:pl": "patternlab export --config ./apps/node-pl/patternlab-config.json",
"dev:pl-node": "cross-env-shell NODE_ENV=development \"npm run pl-node & webpack-dev-server --config ./apps/node-pl/webpack.config.js --hot\"",
"build:pl": "cross-env-shell NODE_ENV=production \"patternlab build --config ./apps/node-pl/patternlab-config.json && webpack --config ./apps/node-pl/webpack.config.js\"",
"build:pl": "cross-env-shell NODE_ENV=production \"npm run pl-node && webpack --config ./apps/node-pl/webpack.config.js\"",
"dev:drupal": "cross-env-shell NODE_ENV=development \"webpack --watch --config ./apps/drupal/webpack.config.js\"",
"build:drupal": "cross-env-shell NODE_ENV=production \"webpack --config ./apps/drupal/webpack.config.js\"",
"lint:js": "eslint --ext .js,.vue ./",
Expand Down
1 change: 1 addition & 0 deletions webpack.particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
sourceMap: NODE_ENV === 'production',
cache: true,
parallel: true,
}),
Expand Down

0 comments on commit aa1a0bf

Please sign in to comment.