@nx-plus/vue
Version:
Vue plugin for Nx
67 lines • 3.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const utils_1 = require("../../utils");
const webpack_1 = require("../../webpack");
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Service = require('@vue/cli-service/lib/Service');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { resolvePkg } = require('@vue/cli-shared-utils/lib/pkg');
function runExecutor(options, context) {
var _a;
return tslib_1.__asyncGenerator(this, arguments, function* runExecutor_1() {
try {
const projectRoot = (0, utils_1.getProjectRoot)(context);
const babelConfig = yield tslib_1.__await((0, utils_1.getBabelConfig)(projectRoot));
const inlineOptions = {
chainWebpack: (config) => {
(0, webpack_1.modifyTsConfigPaths)(config, options, context);
(0, webpack_1.modifyTypescriptAliases)(config, options, context);
(0, webpack_1.modifyCopyAssets)(config, options, context, projectRoot);
if (babelConfig) {
(0, webpack_1.modifyBabelLoader)(config, babelConfig);
}
},
css: options.css,
configureWebpack: yield tslib_1.__await((0, utils_1.resolveConfigureWebpack)(projectRoot)),
};
(0, utils_1.checkUnsupportedConfig)(context, projectRoot);
const service = new Service(projectRoot, {
pkg: resolvePkg(context.root),
inlineOptions,
});
const buildOptions = {
mode: 'production',
dest: path.join(context.root, options.dest),
clean: options.clean,
report: options.report,
'report-json': options.reportJson,
'skip-plugins': options.skipPlugins,
target: 'lib',
entry: path.join(context.root, options.entry),
'inline-vue': options.inlineVue,
watch: options.watch,
formats: options.formats,
name: (_a = options.name) !== null && _a !== void 0 ? _a : context.targetName,
filename: options.filename,
transpileDependencies: options.transpileDependencies,
};
yield tslib_1.__await(service.run('build', buildOptions, ['build']));
yield yield tslib_1.__await({
success: true,
});
if (options.watch) {
// This Promise intentionally never resolves, leaving the process running
// eslint-disable-next-line @typescript-eslint/no-empty-function
yield tslib_1.__await(new Promise(() => { }));
}
}
catch (err) {
console.error(err);
yield yield tslib_1.__await({ success: false });
}
});
}
exports.default = runExecutor;
//# sourceMappingURL=executor.js.map