diff --git a/config/loaders/wxml-loader.js b/config/loaders/wxml-loader.js index 7cbeb74..2c0c9d0 100644 --- a/config/loaders/wxml-loader.js +++ b/config/loaders/wxml-loader.js @@ -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}}}`); } } diff --git a/config/webpack.config.js b/config/webpack.config.js index cd63681..c4a8940 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -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: {}, }, ], }, diff --git a/lib/build.d.ts b/lib/build.d.ts index e670f7c..64ee805 100644 --- a/lib/build.d.ts +++ b/lib/build.d.ts @@ -1 +1 @@ -export default function build(env: string): Promise; +export default function build(cmd: any): Promise; diff --git a/lib/build.js b/lib/build.js index 975bc52..5d286b5 100644 --- a/lib/build.js +++ b/lib/build.js @@ -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, }); diff --git a/lib/index.js b/lib/index.js index 284e499..724798a 100755 --- a/lib/index.js +++ b/lib/index.js @@ -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 ') - .usage('') - .description('build we chat mp of start on demand') + .command('start') + .option('-t, --target ', 'target') + .option('-m, --mode ', 'mode') + .description('build project of start on demand') .action(build_1.default); commander_1.default - .command('build ') - .usage('') - .description('build we chat mp of build on demand') + .command('build') + .option('-t, --target ', 'target') + .option('-m, --mode ', 'mode') + .description('build project of build on demand') .action(build_1.default); commander_1.default .command('create ') diff --git a/lib/template.js b/lib/template.js index 635e0fd..507c027 100644 --- a/lib/template.js +++ b/lib/template.js @@ -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": "", diff --git a/package.json b/package.json index f9ce3f7..8a6b624 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugins/WechatMpPlugin.js b/plugins/WechatMpPlugin.js index d824194..5fc2a45 100644 --- a/plugins/WechatMpPlugin.js +++ b/plugins/WechatMpPlugin.js @@ -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 () => { diff --git a/src/build.ts b/src/build.ts index b141b11..e2ce4f0 100644 --- a/src/build.ts +++ b/src/build.ts @@ -9,21 +9,21 @@ import { } from './tip-style'; import spawn from 'cross-spawn'; -export default async function build(env: string) { - Success(`${success(`build环境:${env}`)}`); - const result = spawn.sync( - `cross-env NODE_ENV=${env} "${process.execPath}"`, - [require.resolve('../scripts/' + 'webpack.js')], - { - stdio: 'inherit', - shell: true, - } - ); - +export default async function build(cmd: any) { + Success(`${success(`build ${cmd.target} environment: ${cmd.mode}`)}`); + const result = spawn.sync( + `cross-env NODE_ENV=${cmd.mode} "${process.execPath}"`, + [require.resolve('../scripts/' + 'webpack.js')], + { + stdio: 'inherit', + shell: true, + } + ); + // const result = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true }); - if (result.status === 0) { - Success(`${success(`执行完成`)}`); - } else { - Error(`${error(`执行失败`)}`); - } + if (result.status === 0) { + Success(`${success(`执行完成`)}`); + } else { + Error(`${error(`执行失败`)}`); + } } diff --git a/src/index.ts b/src/index.ts index ea80c42..a9b15ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,14 +48,16 @@ program .description('build oak app domain of make on demand') .action(make); program - .command('start ') - .usage('') - .description('build we chat mp of start on demand') + .command('start') + .option('-t, --target ', 'target') + .option('-m, --mode ', 'mode') + .description('build project of start on demand') .action(build); program - .command('build ') - .usage('') - .description('build we chat mp of build on demand') + .command('build') + .option('-t, --target ', 'target') + .option('-m, --mode ', 'mode') + .description('build project of build on demand') .action(build); program .command('create ') diff --git a/src/template.ts b/src/template.ts index 9d922fe..a2c71c7 100644 --- a/src/template.ts +++ b/src/template.ts @@ -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": "",