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