This commit is contained in:
Xu Chang 2023-01-30 17:13:37 +08:00
commit 224f60d385
9 changed files with 31 additions and 18 deletions

View File

@ -17,7 +17,7 @@ let moduleFileExtensions = [
'mp.ts',
'ts',
];
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production' && process.env.PROD !== 'true') {
moduleFileExtensions = [
'dev.mp.js',
'dev.mp.ts',

View File

@ -40,7 +40,7 @@ let moduleFileExtensions = [
'pc.jsx',
'jsx',
];
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production' && process.env.PROD !== 'true') {
moduleFileExtensions = [
'dev.web.js',
'dev.web.ts',
@ -49,8 +49,7 @@ if (process.env.NODE_ENV !== 'production') {
'dev.ts',
'dev.tsx',
].concat(moduleFileExtensions);
}
else {
} else {
moduleFileExtensions = [
'prod.web.js',
'prod.web.ts',

View File

@ -11,15 +11,16 @@ async function build(cmd) {
//ts类型检查 waring 还是error,
//主要web受影响error级别的话 控制台和网页都报错warning级别的话 控制台报错
const TSC_COMPILE_ON_ERROR = cmd.check !== 'error';
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build ${cmd.target} environment: ${cmd.mode}`)}`);
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build ${cmd.target} environment: ${cmd.mode} prod: ${!!cmd.prod}`)}`);
if (cmd.target === 'mp' || cmd.target === 'wechatMp') {
const result = cross_spawn_1.default.sync(`cross-env`, [
`NODE_ENV=${cmd.mode}`,
`NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
`COMPILE_ANALYZE=${cmd.analyze}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`node`,
require.resolve(`../scripts/${cmd.mode === 'production'
? 'build-mp.js'
@ -41,8 +42,9 @@ async function build(cmd) {
`NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
`COMPILE_ANALYZE=${cmd.analyze}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`node`,
require.resolve(`../scripts/${cmd.mode === 'production'
? 'build-web.js'

View File

@ -48,6 +48,7 @@ commander_1.default
.command('start')
.option('--sourceMap', 'sourceMap')
.option('--analyze', 'analyze')
.option('--prod', 'prod')
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')

View File

@ -33,9 +33,11 @@ function packageJsonContent({ name, version, description, cliVersion, cliName, c
"scripts": {
"make:domain": "${cliBinName} make",
"start:mp": "${cliBinName} start --target mp --mode development",
"start:mp:prod": "${cliBinName} start --target mp --mode development --prod",
"build:mp": "${cliBinName} build --target mp --mode production",
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
"start:web": "${cliBinName} start --target web --mode development",
"start:web:prod": "${cliBinName} start --target web --mode development --prod",
"build:web": "${cliBinName} build --target web --mode production",
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",

View File

@ -12,6 +12,10 @@ const env = getClientEnvironment();
fs.emptyDirSync(paths.appBuild);
//copy
const { copyLocaleFiles } = require('./locales/copy-mp-locales');
copyLocaleFiles();
webpack(config, (err, stats) => {
if (err) {
console.log(chalk.red(err.stack || err));

View File

@ -21,7 +21,7 @@ export default async function build(cmd: any) {
//ts类型检查 waring 还是error,
//主要web受影响error级别的话 控制台和网页都报错warning级别的话 控制台报错
const TSC_COMPILE_ON_ERROR = cmd.check !== 'error';
Success(`${success(`build ${cmd.target} environment: ${cmd.mode}`)}`);
Success(`${success(`build ${cmd.target} environment: ${cmd.mode} prod: ${!!cmd.prod}`)}`);
if (cmd.target === 'mp' || cmd.target === 'wechatMp') {
const result = spawn.sync(
`cross-env`,
@ -30,8 +30,9 @@ export default async function build(cmd: any) {
`NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
`COMPILE_ANALYZE=${cmd.analyze}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`node`,
require.resolve(
`../scripts/${
@ -59,8 +60,9 @@ export default async function build(cmd: any) {
`NODE_TARGET=${cmd.target}`,
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
`COMPILE_ANALYZE=${cmd.analyze}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`node`,
require.resolve(
`../scripts/${

View File

@ -52,6 +52,7 @@ program
.command('start')
.option('--sourceMap', 'sourceMap')
.option('--analyze', 'analyze')
.option('--prod', 'prod')
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')

View File

@ -40,9 +40,11 @@ export function packageJsonContent({
"scripts": {
"make:domain": "${cliBinName} make",
"start:mp": "${cliBinName} start --target mp --mode development",
"start:mp:prod": "${cliBinName} start --target mp --mode development --prod",
"build:mp": "${cliBinName} build --target mp --mode production",
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
"start:web": "${cliBinName} start --target web --mode development",
"start:web:prod": "${cliBinName} start --target web --mode development --prod",
"build:web": "${cliBinName} build --target web --mode production",
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",