Skip to content

Commit

Permalink
fix(webpack): bring back au run --env prod
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Sep 16, 2019
1 parent 0b8af67 commit eeebdc8
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 11 deletions.
24 changes: 21 additions & 3 deletions skeleton/webpack/aurelia_project/tasks/build.ext
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import { NPM } from 'aurelia-cli';

export default function() {
console.log('`au build` is an alias of the `npm run build`, you may use either of those; see README for more details.');

console.log('`au build` is an alias of the `npm run build:dev`, you may use either of those; see README for more details.');
const args = process.argv.slice(3);
return (new NPM()).run('run', ['build', '--', ...args]);
return (new NPM()).run('run', ['build:dev', '--', ... cleanArgs(args)]);
}

// Cleanup --env prod to --env.production
// for backwards compatability
function cleanArgs(args) {
const cleaned = [];
for (let i = 0, ii = args.length; i < ii; i++) {
if (args[i] === '--env' && i < ii - 1) {
const env = args[++i].toLowerCase();
if (env.startsWith('prod')) {
cleaned.push('--env.production');
} else if (env.startsWith('test')) {
cleaned.push('--tests');
}
} else {
cleaned.push(args[i]);
}
}
return cleaned;
}
23 changes: 20 additions & 3 deletions skeleton/webpack/aurelia_project/tasks/build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
{
"name": "build",
"description": "Builds and processes all application assets. It is an alias of the `npm run build`, you may use either of those; see README for more details."
{
"name": "build",
"description": "Builds and processes all application assets. It is an alias of the `npm run build`, you may use either of those; see README for more details.",
"flags": [
{
"name": "analyze",
"description": "Enable Webpack Bundle Analyzer. Typically paired with --env prod",
"type": "boolean"
},
{
"name": "env",
"description": "Sets the build environment.",
"type": "string"
},
{
"name": "watch",
"description": "Watches source files for changes and refreshes the bundles automatically.",
"type": "boolean"
}
]
}
23 changes: 21 additions & 2 deletions skeleton/webpack/aurelia_project/tasks/run.ext
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,29 @@ import * as kill from 'tree-kill';

const npm = new NPM();

const run = () => {
function run() {
console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.');
const args = process.argv.slice(3);
return npm.run('start', ['--', ...args]);
return npm.run('start', ['--', ... cleanArgs(args)]);
}

// Cleanup --env prod to --env.production
// for backwards compatability
function cleanArgs(args) {
const cleaned = [];
for (let i = 0, ii = args.length; i < ii; i++) {
if (args[i] === '--env' && i < ii - 1) {
const env = args[++i].toLowerCase();
if (env.startsWith('prod')) {
cleaned.push('--env.production');
} else if (env.startsWith('test')) {
cleaned.push('--tests');
}
} else {
cleaned.push(args[i]);
}
}
return cleaned;
}

const shutdownAppServer = () => {
Expand Down
38 changes: 35 additions & 3 deletions skeleton/webpack/aurelia_project/tasks/run.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
{
"name": "run",
"description": "Builds the application and serves up the assets via a local web server, watching files for changes as you work. It is an alias of the `npm start`, you may use either of those; see README for more details."
{
"name": "run",
"description": "Builds the application and serves up the assets via a local web server, watching files for changes as you work. It is an alias of the `npm start`, you may use either of those; see README for more details.",
"flags": [
{
"name": "analyze",
"description": "Enable Webpack Bundle Analyzer. Typically paired with --env prod",
"type": "boolean"
},
{
"name": "env",
"description": "Sets the build environment.",
"type": "string"
},
{
"name": "hmr",
"description": "Enable Hot Module Reload",
"type": "boolean"
},
{
"name": "port",
"description": "Set port number of the dev server",
"type": "string"
},
{
"name": "host",
"description": "Set host address of the dev server, the accessible URL",
"type": "string"
},
{
"name": "open",
"description": "Open the default browser at the application location.",
"type": "boolean"
}
]
}

0 comments on commit eeebdc8

Please sign in to comment.