oak-cli build 命令改

This commit is contained in:
Wang Kejun 2022-04-25 13:23:50 +08:00
parent fe1ce346ea
commit 4d6c25aeca
11 changed files with 50 additions and 49 deletions

View File

@ -15,7 +15,10 @@ function traverse(doc, callback) {
}
module.exports = function (content) {
//console.log(content);
const options = this.getOptions() || {}; //获取配置参数
// const callback = this.async();
// console.log(content, options);
const doc = new DOMParser().parseFromString(content, 'text/xml');
traverse(doc, (node) => {
if (node.nodeType === node.ELEMENT_NODE) {
@ -28,8 +31,7 @@ module.exports = function (content) {
if (node.hasAttribute('oak:forbidFocus')) {
node.removeAttribute('oak:forbidFocus');
}
else {
} else {
node.setAttribute('focus', `{{!!oakFocused.${oakValue}}}`);
}
}

View File

@ -95,7 +95,8 @@ module.exports = {
},
{
test: /\.less$/,
include: /oak-general-business\/wechatMp|oak-general-business\\wechatMp/,
include:
/oak-general-business\/wechatMp|oak-general-business\\wechatMp/,
// include: [
// path.resolve(
// process.cwd(),
@ -158,17 +159,12 @@ module.exports = {
{
test: /\.(xml|wxml)$/,
include: /oak-general-business\/wechatMp|oak-general-business\\wechatMp/,
// include: [
// path.resolve(
// process.cwd(),
// 'node_modules/oak-general-business/wechatMp'
// ),
// ],
type: 'javascript/auto',
use: [
oakFileLoader('wxml'),
{
loader: 'wxml-loader',
options: {},
},
],
},

2
lib/build.d.ts vendored
View File

@ -1 +1 @@
export default function build(env: string): Promise<void>;
export default function build(cmd: any): Promise<void>;

View File

@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const tip_style_1 = require("./tip-style");
const cross_spawn_1 = __importDefault(require("cross-spawn"));
async function build(env) {
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build环境:${env}`)}`);
const result = cross_spawn_1.default.sync(`cross-env NODE_ENV=${env} "${process.execPath}"`, [require.resolve('../scripts/' + 'webpack.js')], {
async function build(cmd) {
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build ${cmd.target} environment: ${cmd.mode}`)}`);
const result = cross_spawn_1.default.sync(`cross-env NODE_ENV=${cmd.mode} "${process.execPath}"`, [require.resolve('../scripts/' + 'webpack.js')], {
stdio: 'inherit',
shell: true,
});

View File

@ -46,14 +46,16 @@ commander_1.default
.description('build oak app domain of make on demand')
.action(make_1.default);
commander_1.default
.command('start <env>')
.usage('<env>')
.description('build we chat mp of start on demand')
.command('start')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.description('build project of start on demand')
.action(build_1.default);
commander_1.default
.command('build <env>')
.usage('<env>')
.description('build we chat mp of build on demand')
.command('build')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.description('build project of build on demand')
.action(build_1.default);
commander_1.default
.command('create <name>')

View File

@ -23,8 +23,8 @@ function packageJsonContent({ name, version, description, cliversion, cliname, i
"description": "${description}",
"scripts": {
"make:domain": "${cliname} make",
"start:mp": "${cliname} start development",
"build:mp": "${cliname} build production"
"start:mp": "${cliname} start --target mp --mode development",
"build:mp": "${cliname} build --target mp --mode production"
},
"keywords": [],
"author": "",

View File

@ -39,7 +39,6 @@
"fs-extra": "^10.0.0",
"globby": "^11.1.0",
"inquirer": "^7.3.3",
"loader-utils": "^3.2.0",
"mini-css-extract-plugin": "^2.5.3",
"postcss-less": "^6.0.0",
"progress-bar-webpack-plugin": "^2.1.0",

View File

@ -504,7 +504,7 @@ class OakWeChatMpPlugin {
const emitAssets = [];
for (let entry of this.assetsEntry) {
const assets = path.resolve(this.basePath, entry);
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
if (/\.(sass|scss|css|less|styl|xml|wxml)$/.test(assets)) {
continue;
}
const toTmit = async () => {
@ -539,7 +539,7 @@ class OakWeChatMpPlugin {
}
for (let entry of this.oakAssetsEntry) {
const assets = path.resolve(process.cwd(), entry);
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
if (/\.(sass|scss|css|less|styl|xml|wxml)$/.test(assets)) {
continue;
}
const toTmit = async () => {

View File

@ -9,10 +9,10 @@ import {
} from './tip-style';
import spawn from 'cross-spawn';
export default async function build(env: string) {
Success(`${success(`build环境:${env}`)}`);
export default async function build(cmd: any) {
Success(`${success(`build ${cmd.target} environment: ${cmd.mode}`)}`);
const result = spawn.sync(
`cross-env NODE_ENV=${env} "${process.execPath}"`,
`cross-env NODE_ENV=${cmd.mode} "${process.execPath}"`,
[require.resolve('../scripts/' + 'webpack.js')],
{
stdio: 'inherit',

View File

@ -48,14 +48,16 @@ program
.description('build oak app domain of make on demand')
.action(make);
program
.command('start <env>')
.usage('<env>')
.description('build we chat mp of start on demand')
.command('start')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.description('build project of start on demand')
.action(build);
program
.command('build <env>')
.usage('<env>')
.description('build we chat mp of build on demand')
.command('build')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.description('build project of build on demand')
.action(build);
program
.command('create <name>')

View File

@ -29,8 +29,8 @@ export function packageJsonContent({
"description": "${description}",
"scripts": {
"make:domain": "${cliname} make",
"start:mp": "${cliname} start development",
"build:mp": "${cliname} build production"
"start:mp": "${cliname} start --target mp --mode development",
"build:mp": "${cliname} build --target mp --mode production"
},
"keywords": [],
"author": "",