Skip to content
Permalink
Browse files

fix(webpack): bring back au run --env prod

  • Loading branch information...
3cp committed Sep 10, 2019
1 parent 8a4ceeb commit a31ac3744f3adfd5657386f5ed595f0788879bf1
@@ -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;
}
@@ -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"
}
]
}
@@ -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 = () => {
@@ -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 a31ac37

Please sign in to comment.
You can’t perform that action at this time.