merge
This commit is contained in:
commit
224f60d385
|
|
@ -17,7 +17,7 @@ let moduleFileExtensions = [
|
||||||
'mp.ts',
|
'mp.ts',
|
||||||
'ts',
|
'ts',
|
||||||
];
|
];
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production' && process.env.PROD !== 'true') {
|
||||||
moduleFileExtensions = [
|
moduleFileExtensions = [
|
||||||
'dev.mp.js',
|
'dev.mp.js',
|
||||||
'dev.mp.ts',
|
'dev.mp.ts',
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ let moduleFileExtensions = [
|
||||||
'pc.jsx',
|
'pc.jsx',
|
||||||
'jsx',
|
'jsx',
|
||||||
];
|
];
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production' && process.env.PROD !== 'true') {
|
||||||
moduleFileExtensions = [
|
moduleFileExtensions = [
|
||||||
'dev.web.js',
|
'dev.web.js',
|
||||||
'dev.web.ts',
|
'dev.web.ts',
|
||||||
|
|
@ -49,16 +49,15 @@ if (process.env.NODE_ENV !== 'production') {
|
||||||
'dev.ts',
|
'dev.ts',
|
||||||
'dev.tsx',
|
'dev.tsx',
|
||||||
].concat(moduleFileExtensions);
|
].concat(moduleFileExtensions);
|
||||||
}
|
} else {
|
||||||
else {
|
moduleFileExtensions = [
|
||||||
moduleFileExtensions = [
|
'prod.web.js',
|
||||||
'prod.web.js',
|
'prod.web.ts',
|
||||||
'prod.web.ts',
|
'prod.web.tsx',
|
||||||
'prod.web.tsx',
|
'prod.js',
|
||||||
'prod.js',
|
'prod.ts',
|
||||||
'prod.ts',
|
'prod.tsx',
|
||||||
'prod.tsx',
|
].concat(moduleFileExtensions);
|
||||||
].concat(moduleFileExtensions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve file paths in the same order as webpack
|
// Resolve file paths in the same order as webpack
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,16 @@ async function build(cmd) {
|
||||||
//ts类型检查 waring 还是error,
|
//ts类型检查 waring 还是error,
|
||||||
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
||||||
const TSC_COMPILE_ON_ERROR = cmd.check !== 'error';
|
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') {
|
if (cmd.target === 'mp' || cmd.target === 'wechatMp') {
|
||||||
const result = cross_spawn_1.default.sync(`cross-env`, [
|
const result = cross_spawn_1.default.sync(`cross-env`, [
|
||||||
`NODE_ENV=${cmd.mode}`,
|
`NODE_ENV=${cmd.mode}`,
|
||||||
`NODE_TARGET=${cmd.target}`,
|
`NODE_TARGET=${cmd.target}`,
|
||||||
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
|
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
|
||||||
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
||||||
`COMPILE_ANALYZE=${cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
|
`PROD=${!!cmd.prod}`,
|
||||||
`node`,
|
`node`,
|
||||||
require.resolve(`../scripts/${cmd.mode === 'production'
|
require.resolve(`../scripts/${cmd.mode === 'production'
|
||||||
? 'build-mp.js'
|
? 'build-mp.js'
|
||||||
|
|
@ -41,8 +42,9 @@ async function build(cmd) {
|
||||||
`NODE_TARGET=${cmd.target}`,
|
`NODE_TARGET=${cmd.target}`,
|
||||||
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
|
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
|
||||||
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
||||||
`COMPILE_ANALYZE=${cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
|
`PROD=${!!cmd.prod}`,
|
||||||
`node`,
|
`node`,
|
||||||
require.resolve(`../scripts/${cmd.mode === 'production'
|
require.resolve(`../scripts/${cmd.mode === 'production'
|
||||||
? 'build-web.js'
|
? 'build-web.js'
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ commander_1.default
|
||||||
.command('start')
|
.command('start')
|
||||||
.option('--sourceMap', 'sourceMap')
|
.option('--sourceMap', 'sourceMap')
|
||||||
.option('--analyze', 'analyze')
|
.option('--analyze', 'analyze')
|
||||||
|
.option('--prod', 'prod')
|
||||||
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
|
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
|
||||||
.option('-t, --target <target>', 'target')
|
.option('-t, --target <target>', 'target')
|
||||||
.option('-m, --mode <mode>', 'mode')
|
.option('-m, --mode <mode>', 'mode')
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,11 @@ function packageJsonContent({ name, version, description, cliVersion, cliName, c
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"make:domain": "${cliBinName} make",
|
"make:domain": "${cliBinName} make",
|
||||||
"start:mp": "${cliBinName} start --target mp --mode development",
|
"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:mp": "${cliBinName} build --target mp --mode production",
|
||||||
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
|
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
|
||||||
"start:web": "${cliBinName} start --target web --mode development",
|
"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:web": "${cliBinName} build --target web --mode production",
|
||||||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ const env = getClientEnvironment();
|
||||||
|
|
||||||
fs.emptyDirSync(paths.appBuild);
|
fs.emptyDirSync(paths.appBuild);
|
||||||
|
|
||||||
|
//copy
|
||||||
|
const { copyLocaleFiles } = require('./locales/copy-mp-locales');
|
||||||
|
copyLocaleFiles();
|
||||||
|
|
||||||
webpack(config, (err, stats) => {
|
webpack(config, (err, stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(chalk.red(err.stack || err));
|
console.log(chalk.red(err.stack || err));
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export default async function build(cmd: any) {
|
||||||
//ts类型检查 waring 还是error,
|
//ts类型检查 waring 还是error,
|
||||||
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
||||||
const TSC_COMPILE_ON_ERROR = cmd.check !== 'error';
|
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') {
|
if (cmd.target === 'mp' || cmd.target === 'wechatMp') {
|
||||||
const result = spawn.sync(
|
const result = spawn.sync(
|
||||||
`cross-env`,
|
`cross-env`,
|
||||||
|
|
@ -30,8 +30,9 @@ export default async function build(cmd: any) {
|
||||||
`NODE_TARGET=${cmd.target}`,
|
`NODE_TARGET=${cmd.target}`,
|
||||||
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
|
`SUB_DIR_NAME=${cmd.subDir || 'wechatMp'}`,
|
||||||
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
||||||
`COMPILE_ANALYZE=${cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
|
`PROD=${!!cmd.prod}`,
|
||||||
`node`,
|
`node`,
|
||||||
require.resolve(
|
require.resolve(
|
||||||
`../scripts/${
|
`../scripts/${
|
||||||
|
|
@ -59,8 +60,9 @@ export default async function build(cmd: any) {
|
||||||
`NODE_TARGET=${cmd.target}`,
|
`NODE_TARGET=${cmd.target}`,
|
||||||
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
|
`SUB_DIR_NAME=${cmd.subDir || 'web'}`,
|
||||||
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
`TSC_COMPILE_ON_ERROR=${TSC_COMPILE_ON_ERROR}`,
|
||||||
`COMPILE_ANALYZE=${cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
|
`PROD=${!!cmd.prod}`,
|
||||||
`node`,
|
`node`,
|
||||||
require.resolve(
|
require.resolve(
|
||||||
`../scripts/${
|
`../scripts/${
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ program
|
||||||
.command('start')
|
.command('start')
|
||||||
.option('--sourceMap', 'sourceMap')
|
.option('--sourceMap', 'sourceMap')
|
||||||
.option('--analyze', 'analyze')
|
.option('--analyze', 'analyze')
|
||||||
|
.option('--prod', 'prod')
|
||||||
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
|
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
|
||||||
.option('-t, --target <target>', 'target')
|
.option('-t, --target <target>', 'target')
|
||||||
.option('-m, --mode <mode>', 'mode')
|
.option('-m, --mode <mode>', 'mode')
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,11 @@ export function packageJsonContent({
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"make:domain": "${cliBinName} make",
|
"make:domain": "${cliBinName} make",
|
||||||
"start:mp": "${cliBinName} start --target mp --mode development",
|
"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:mp": "${cliBinName} build --target mp --mode production",
|
||||||
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
|
"build-analyze:mp": "${cliBinName} build --target mp --mode production --analyze",
|
||||||
"start:web": "${cliBinName} start --target web --mode development",
|
"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:web": "${cliBinName} build --target web --mode production",
|
||||||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue