@sanpjs/cmd-build
Version:
Sanp build command
60 lines • 1.81 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.builder = exports.description = exports.command = void 0;
/**
* @file main process
* @author zttonly <zttonly@baidu.com>
*/
const bundler_webpack_1 = __importDefault(require("@sanpjs/bundler-webpack"));
const builder_1 = __importDefault(require("@sanpjs/builder"));
const core_1 = __importDefault(require("@sanpjs/core"));
exports.command = 'build [entry]';
exports.description = 'Compiles an app into an output directory named dist';
exports.builder = {
config: {
alias: 'config-file',
type: 'string',
hidden: true,
describe: 'Project config file'
},
mode: {
hidden: true,
type: 'string',
default: 'production',
choices: ['development', 'production'],
describe: 'Operating environment'
},
analyze: {
type: 'boolean',
describe: 'Enable webpack-bundle-analyzer server'
},
clean: {
type: 'boolean',
describe: 'Delete the output directory before building'
},
watch: {
alias: 'w',
type: 'boolean',
describe: 'Watch mode'
},
'stats-json': {
alias: 'stats',
type: 'boolean',
describe: 'Generate webpack stats JSON file'
}
};
const handler = (args) => {
const sanp = (0, core_1.default)({ Bundler: bundler_webpack_1.default, Builder: builder_1.default });
// watch
sanp.run(args, (err) => {
if (err) {
sanp.context.logger.error(err);
process.exit(1);
}
});
};
exports.handler = handler;
//# sourceMappingURL=index.js.map