移除PROD参数 编译支持带sourcemap模式
This commit is contained in:
parent
6100bfa503
commit
d5cb474480
|
|
@ -58,7 +58,6 @@ function getClientEnvironment() {
|
||||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||||
// process.env.OAK_PLATFORM: wechatMp | web | node
|
// process.env.OAK_PLATFORM: wechatMp | web | node
|
||||||
OAK_PLATFORM: 'wechatMp',
|
OAK_PLATFORM: 'wechatMp',
|
||||||
PROD: process.env.PROD,
|
|
||||||
OAK_DEV_MODE: process.env.OAK_DEV_MODE || 'server',
|
OAK_DEV_MODE: process.env.OAK_DEV_MODE || 'server',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ let moduleFileExtensions = [
|
||||||
'ts',
|
'ts',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (process.env.PROD === 'true' || process.env.OAK_DEV_MODE === 'server') {
|
if (process.env.OAK_DEV_MODE === 'server') {
|
||||||
moduleFileExtensions = [
|
moduleFileExtensions = [
|
||||||
'server.js',
|
'server.js',
|
||||||
'server.ts',
|
'server.ts',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ module.exports = function (webpackEnv) {
|
||||||
// staging 把mode改为none,其他跟production一样
|
// staging 把mode改为none,其他跟production一样
|
||||||
const isEnvStaging = webpackEnv === 'staging';
|
const isEnvStaging = webpackEnv === 'staging';
|
||||||
const isEnvDevelopment = webpackEnv === 'development';
|
const isEnvDevelopment = webpackEnv === 'development';
|
||||||
const isEnvProduction = webpackEnv === 'production' || isEnvStaging;
|
const isEnvProduction = webpackEnv === 'production';
|
||||||
|
|
||||||
const oakFileLoader = (ext = '[ext]') => {
|
const oakFileLoader = (ext = '[ext]') => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -95,12 +95,13 @@ module.exports = function (webpackEnv) {
|
||||||
? 'production'
|
? 'production'
|
||||||
: isEnvDevelopment && 'development',
|
: isEnvDevelopment && 'development',
|
||||||
// Stop compilation early in production
|
// Stop compilation early in production
|
||||||
bail: isEnvProduction,
|
bail: isEnvProduction || isEnvStaging,
|
||||||
devtool: isEnvProduction
|
devtool:
|
||||||
? shouldUseSourceMap
|
isEnvProduction || isEnvStaging
|
||||||
? 'source-map'
|
? shouldUseSourceMap
|
||||||
: false
|
? 'source-map'
|
||||||
: isEnvDevelopment && 'cheap-module-source-map',
|
: false
|
||||||
|
: isEnvDevelopment && 'cheap-module-source-map',
|
||||||
entry: {
|
entry: {
|
||||||
app: paths.appIndexJs,
|
app: paths.appIndexJs,
|
||||||
},
|
},
|
||||||
|
|
@ -188,7 +189,7 @@ module.exports = function (webpackEnv) {
|
||||||
// 标记未被使用的代码
|
// 标记未被使用的代码
|
||||||
usedExports: true,
|
usedExports: true,
|
||||||
// 删除 usedExports 标记的未使用的代码
|
// 删除 usedExports 标记的未使用的代码
|
||||||
minimize: isEnvProduction,
|
minimize: isEnvProduction || isEnvStaging,
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
extractComments: false,
|
extractComments: false,
|
||||||
|
|
@ -251,8 +252,6 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [oakI18nPlugin, oakPathPlugin],
|
plugins: [oakI18nPlugin, oakPathPlugin],
|
||||||
//开启缓存
|
|
||||||
// cacheDirectory: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -265,8 +264,6 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [oakI18nPlugin, oakPathPlugin],
|
plugins: [oakI18nPlugin, oakPathPlugin],
|
||||||
//开启缓存
|
|
||||||
// cacheDirectory: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -293,7 +290,6 @@ module.exports = function (webpackEnv) {
|
||||||
appSrcPath: paths.appSrc,
|
appSrcPath: paths.appSrc,
|
||||||
appRootPath: paths.appRootPath,
|
appRootPath: paths.appRootPath,
|
||||||
appRootSrcPath: paths.appRootSrc,
|
appRootSrcPath: paths.appRootSrc,
|
||||||
cacheDirectory: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -323,9 +319,9 @@ module.exports = function (webpackEnv) {
|
||||||
include: ['project.config.json', 'sitemap.json'],
|
include: ['project.config.json', 'sitemap.json'],
|
||||||
debugPanel: {
|
debugPanel: {
|
||||||
name: 'oak-debugPanel',
|
name: 'oak-debugPanel',
|
||||||
show: !isEnvProduction,
|
show: !(isEnvProduction || isEnvStaging),
|
||||||
},
|
},
|
||||||
split: isEnvProduction ? true : false,
|
split: isEnvProduction || isEnvStaging ? true : false,
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin(env.stringified),
|
new webpack.DefinePlugin(env.stringified),
|
||||||
new StylelintPlugin({
|
new StylelintPlugin({
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ const watchFolders = [
|
||||||
|
|
||||||
let moduleFileExtensions = ['js', 'ts', 'jsx', 'tsx', 'less', 'json', 'svg'];
|
let moduleFileExtensions = ['js', 'ts', 'jsx', 'tsx', 'less', 'json', 'svg'];
|
||||||
|
|
||||||
if (process.env.PROD === 'true' || process.env.OAK_DEV_MODE === 'server') {
|
if (process.env.OAK_DEV_MODE === 'server') {
|
||||||
moduleFileExtensions = [
|
moduleFileExtensions = [
|
||||||
'server.js',
|
'server.js',
|
||||||
'server.ts',
|
'server.ts',
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ function getClientEnvironment(publicUrl) {
|
||||||
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
|
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
|
||||||
// process.env.OAK_PLATFORM: wechatMp | web | native
|
// process.env.OAK_PLATFORM: wechatMp | web | native
|
||||||
OAK_PLATFORM: 'web',
|
OAK_PLATFORM: 'web',
|
||||||
PROD: process.env.PROD,
|
|
||||||
OAK_DEV_MODE: process.env.OAK_DEV_MODE || 'server',
|
OAK_DEV_MODE: process.env.OAK_DEV_MODE || 'server',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ let moduleFileExtensions = [
|
||||||
'jsx',
|
'jsx',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (process.env.PROD === 'true' || process.env.OAK_DEV_MODE === 'server') {
|
if (process.env.OAK_DEV_MODE === 'server') {
|
||||||
moduleFileExtensions = [
|
moduleFileExtensions = [
|
||||||
'server.mjs',
|
'server.mjs',
|
||||||
'server.js',
|
'server.js',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ async function build(cmd) {
|
||||||
`SUB_DIR_NAME=${subdir}`,
|
`SUB_DIR_NAME=${subdir}`,
|
||||||
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
||||||
`node`,
|
`node`,
|
||||||
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
|
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
|
||||||
|
|
@ -75,7 +74,6 @@ async function build(cmd) {
|
||||||
`SUB_DIR_NAME=${subdir}`,
|
`SUB_DIR_NAME=${subdir}`,
|
||||||
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
`PORT=${port || 3000}`,
|
`PORT=${port || 3000}`,
|
||||||
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
||||||
`node`,
|
`node`,
|
||||||
|
|
@ -131,7 +129,6 @@ async function build(cmd) {
|
||||||
result = cross_spawn_1.default.sync(`cross-env`, [
|
result = cross_spawn_1.default.sync(`cross-env`, [
|
||||||
`NODE_ENV=${mode}`,
|
`NODE_ENV=${mode}`,
|
||||||
'OAK_PLATFORM=native',
|
'OAK_PLATFORM=native',
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
`OAK_DEV_MODE=${devMode}`,
|
`OAK_DEV_MODE=${devMode}`,
|
||||||
'react-native',
|
'react-native',
|
||||||
'start',
|
'start',
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,8 @@ commander_1.default
|
||||||
.action(makeDependency_1.default);
|
.action(makeDependency_1.default);
|
||||||
commander_1.default
|
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')
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
import { EntityDict } from 'oak-domain/lib/types';
|
import { EntityDict } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>>(path: string, dropIfExists?: boolean): Promise<void>;
|
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>>(path: string): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.initialize = void 0;
|
exports.initialize = void 0;
|
||||||
/// <reference path="../typings/polyfill.d.ts" />
|
/// <reference path="../typings/polyfill.d.ts" />
|
||||||
const oak_backend_base_1 = require("oak-backend-base");
|
const oak_backend_base_1 = require("oak-backend-base");
|
||||||
async function initialize(path, dropIfExists) {
|
async function initialize(path) {
|
||||||
const appLoader = new oak_backend_base_1.AppLoader(path);
|
const appLoader = new oak_backend_base_1.AppLoader(path);
|
||||||
await appLoader.mount(true);
|
await appLoader.mount(true);
|
||||||
await appLoader.initialize(dropIfExists);
|
await appLoader.initialize();
|
||||||
await appLoader.unmount();
|
await appLoader.unmount();
|
||||||
console.log('data initialized');
|
console.log('data initialized');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,10 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
||||||
"start:native": "${cliBinName} start --target rn --mode development --devMode frontend",
|
"start:native": "${cliBinName} start --target rn --mode development --devMode frontend",
|
||||||
"start:native:server": "${cliBinName} start --target rn --mode development",
|
"start:native:server": "${cliBinName} start --target rn --mode development",
|
||||||
"build:web:staging": "${cliBinName} build --target web --mode staging",
|
"build:web:staging": "${cliBinName} build --target web --mode staging",
|
||||||
|
"build-sourcemap:web:staging": "${cliBinName} build --target web --mode staging --sourcemap",
|
||||||
"build-analyze:web:staging": "${cliBinName} build --target web --mode staging --analyze",
|
"build-analyze:web:staging": "${cliBinName} build --target web --mode staging --analyze",
|
||||||
"build:web": "${cliBinName} build --target web --mode production",
|
"build:web": "${cliBinName} build --target web --mode production",
|
||||||
|
"build-sourcemap:web": "${cliBinName} build --target web --mode production --sourcemap",
|
||||||
"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",
|
||||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ export default async function build(cmd: any) {
|
||||||
`SUB_DIR_NAME=${subdir}`,
|
`SUB_DIR_NAME=${subdir}`,
|
||||||
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
||||||
`node`,
|
`node`,
|
||||||
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
|
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
|
||||||
|
|
@ -101,7 +100,6 @@ export default async function build(cmd: any) {
|
||||||
`SUB_DIR_NAME=${subdir}`,
|
`SUB_DIR_NAME=${subdir}`,
|
||||||
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
`COMPILE_ANALYZE=${!!cmd.analyze}`,
|
||||||
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
`PORT=${port || 3000}`,
|
`PORT=${port || 3000}`,
|
||||||
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
|
||||||
`node`,
|
`node`,
|
||||||
|
|
@ -168,7 +166,6 @@ export default async function build(cmd: any) {
|
||||||
[
|
[
|
||||||
`NODE_ENV=${mode}`,
|
`NODE_ENV=${mode}`,
|
||||||
'OAK_PLATFORM=native',
|
'OAK_PLATFORM=native',
|
||||||
`PROD=${!!cmd.prod}`,
|
|
||||||
`OAK_DEV_MODE=${devMode}`,
|
`OAK_DEV_MODE=${devMode}`,
|
||||||
'react-native',
|
'react-native',
|
||||||
'start',
|
'start',
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,8 @@ program
|
||||||
|
|
||||||
program
|
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')
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ import { EntityDict } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||||||
|
|
||||||
export async function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>>(
|
export async function initialize<
|
||||||
path: string,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
dropIfExists?: boolean) {
|
Cxt extends BackendRuntimeContext<ED>
|
||||||
|
>(path: string) {
|
||||||
const appLoader = new AppLoader(path);
|
const appLoader = new AppLoader(path);
|
||||||
await appLoader.mount(true);
|
await appLoader.mount(true);
|
||||||
await appLoader.initialize(dropIfExists);
|
await appLoader.initialize();
|
||||||
await appLoader.unmount();
|
await appLoader.unmount();
|
||||||
console.log('data initialized');
|
console.log('data initialized');
|
||||||
}
|
}
|
||||||
|
|
@ -90,8 +90,10 @@ export function packageJsonContent({
|
||||||
"start:native": "${cliBinName} start --target rn --mode development --devMode frontend",
|
"start:native": "${cliBinName} start --target rn --mode development --devMode frontend",
|
||||||
"start:native:server": "${cliBinName} start --target rn --mode development",
|
"start:native:server": "${cliBinName} start --target rn --mode development",
|
||||||
"build:web:staging": "${cliBinName} build --target web --mode staging",
|
"build:web:staging": "${cliBinName} build --target web --mode staging",
|
||||||
|
"build-sourcemap:web:staging": "${cliBinName} build --target web --mode staging --sourcemap",
|
||||||
"build-analyze:web:staging": "${cliBinName} build --target web --mode staging --analyze",
|
"build-analyze:web:staging": "${cliBinName} build --target web --mode staging --analyze",
|
||||||
"build:web": "${cliBinName} build --target web --mode production",
|
"build:web": "${cliBinName} build --target web --mode production",
|
||||||
|
"build-sourcemap:web": "${cliBinName} build --target web --mode production --sourcemap",
|
||||||
"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",
|
||||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue