适配staging环境

This commit is contained in:
wkj 2024-04-25 16:58:47 +08:00
parent 6d336d19c6
commit 7e72576914
14 changed files with 234 additions and 275 deletions

View File

@ -9,12 +9,8 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const UiExtractPlugin = require('ui-extract-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const ForkTsCheckerWebpackPlugin =
process.env.TSC_COMPILE_ON_ERROR === 'true'
? require('./../../plugins/ForkTsCheckerWarningWebpackPlugin')
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ForkTsCheckerWebpackPlugin = require('./../../plugins/ForkTsCheckerWarningWebpackPlugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const OakWeChatMpPlugin = require('../../plugins/WechatMpPlugin');
@ -46,8 +42,10 @@ const copyPatterns = [].concat(pkg.copyWebpack || []).map((pattern) =>
const oakRegex = /(\/*[a-zA-Z0-9_-])*\/(lib|src|es)\/|(\\*[a-zA-Z0-9_-])*\\(lib|src|es)\\/;
module.exports = function (webpackEnv) {
// staging 把mode改为none其他跟production一样
const isEnvStaging = webpackEnv === 'staging';
const isEnvDevelopment = webpackEnv === 'development';
const isEnvProduction = webpackEnv === 'production';
const isEnvProduction = webpackEnv === 'production' || isEnvStaging;
const oakFileLoader = (ext = '[ext]') => {
return {
@ -91,7 +89,9 @@ module.exports = function (webpackEnv) {
target: ['web'],
// Webpack noise constrained to errors and warnings
stats: 'errors-warnings',
mode: isEnvProduction
mode: isEnvStaging
? 'none'
: isEnvProduction
? 'production'
: isEnvDevelopment && 'development',
// Stop compilation early in production
@ -325,9 +325,7 @@ module.exports = function (webpackEnv) {
name: 'oak-debugPanel',
show: !isEnvProduction,
},
split: isEnvProduction
? true
: isEnvDevelopment && process.env.SPLIT === 'true',
split: isEnvProduction ? true : false,
}),
new webpack.DefinePlugin(env.stringified),
new StylelintPlugin({
@ -352,19 +350,6 @@ module.exports = function (webpackEnv) {
typescriptPath: resolve.sync('typescript', {
basedir: paths.appNodeModules,
}),
// configOverwrite: {
// compilerOptions: {
// sourceMap: isEnvProduction
// ? shouldUseSourceMap
// : isEnvDevelopment,
// skipLibCheck: true,
// inlineSourceMap: false,
// declarationMap: false,
// noEmit: true,
// incremental: true,
// tsBuildInfoFile: paths.appTsBuildInfoFile,
// },
// },
configFile: paths.appTsConfig,
context: paths.appRootPath,
diagnosticOptions: {

View File

@ -20,13 +20,9 @@ const paths = require('./paths');
const modules = require('./modules');
const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const ForkTsCheckerWebpackPlugin =
process.env.TSC_COMPILE_ON_ERROR === 'true'
? require('./../../plugins/ForkTsCheckerWarningWebpackPlugin')
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const ForkTsCheckerWebpackPlugin = require('./../../plugins/ForkTsCheckerWarningWebpackPlugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
@ -102,6 +98,8 @@ const hasJsxRuntime = (() => {
// This is the production and development configuration.
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
module.exports = function (webpackEnv) {
// staging 把mode改为none其他跟production一样
const isEnvStaging = webpackEnv === 'staging';
const isEnvDevelopment = webpackEnv === 'development';
const isEnvProduction = webpackEnv === 'production';
@ -118,7 +116,6 @@ module.exports = function (webpackEnv) {
const shouldUseReactRefresh = env.raw.FAST_REFRESH;
// common function to get style loaders
const getStyleLoaders = (cssOptions, preProcessor, preProcessOptions) => {
const loaders = [
@ -148,34 +145,34 @@ module.exports = function (webpackEnv) {
config: false,
plugins: !useTailwind
? [
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
},
],
// Adds PostCSS Normalize as the reset css with default options,
// so that it honors browserslist config in package.json
// which in turn let's users customize the target behavior as per their needs.
'postcss-normalize',
]
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
},
],
// Adds PostCSS Normalize as the reset css with default options,
// so that it honors browserslist config in package.json
// which in turn let's users customize the target behavior as per their needs.
'postcss-normalize',
]
: [
'tailwindcss',
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
},
],
],
'tailwindcss',
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
},
],
],
},
sourceMap: isEnvProduction
? shouldUseSourceMap
@ -196,9 +193,12 @@ module.exports = function (webpackEnv) {
},
{
loader: require.resolve(preProcessor),
options: Object.assign({
sourceMap: true,
}, preProcessOptions),
options: Object.assign(
{
sourceMap: true,
},
preProcessOptions
),
}
);
}
@ -206,14 +206,17 @@ module.exports = function (webpackEnv) {
};
// 读取编译配置
const compilerConfigurationFile = path.join(paths.appRootPath, 'configuration', 'compiler.js');
const projectConfiguration = fs.existsSync(compilerConfigurationFile) && require(compilerConfigurationFile).webpack;
const compilerConfigurationFile = path.join(
paths.appRootPath,
'configuration',
'compiler.js'
);
const projectConfiguration =
fs.existsSync(compilerConfigurationFile) &&
require(compilerConfigurationFile).webpack;
const getOakInclude = () => {
const result = [
/oak-frontend-base/,
/oak-general-business/,
];
const result = [/oak-frontend-base/, /oak-general-business/];
if (projectConfiguration && projectConfiguration.extraOakModules) {
result.push(...projectConfiguration.extraOakModules);
}
@ -260,14 +263,14 @@ module.exports = function (webpackEnv) {
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: isEnvProduction
? (info) =>
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/')
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/')
: isEnvDevelopment &&
((info) =>
path
.resolve(info.absoluteResourcePath)
.replace(/\\/g, '/')),
((info) =>
path
.resolve(info.absoluteResourcePath)
.replace(/\\/g, '/')),
},
cache: {
type: 'filesystem',
@ -381,14 +384,14 @@ module.exports = function (webpackEnv) {
stream: require.resolve('stream-browserify'),
zlib: require.resolve('browserify-zlib'),
querystring: require.resolve('querystring-es3'),
events: path.resolve(__dirname, '../../node_modules/events'),
events: require.resolve('events/'),
os: false,
url: false,
path: false,
fs: false,
net: false,
tls: false,
}
};
if (
projectConfiguration &&
projectConfiguration.resolve &&
@ -569,10 +572,10 @@ module.exports = function (webpackEnv) {
plugins: [
isEnvDevelopment &&
shouldUseReactRefresh &&
require.resolve(
'react-refresh/babel'
),
shouldUseReactRefresh &&
require.resolve(
'react-refresh/babel'
),
oakPathTsxPlugin,
oakRenderTsxPlugin,
// oakRouterPlugin,
@ -787,14 +790,14 @@ module.exports = function (webpackEnv) {
},
plugins: [
isEnvProduction &&
new CompressionWebpackPlugin({
filename: '[path][base].gz', //压缩后的文件名
algorithm: 'gzip', //压缩格式 有gzip、brotliCompress
test: /\.(js|css|svg)$/,
threshold: 10240, // 只处理比这个值大的资源,按字节算
minRatio: 0.8, //只有压缩率比这个值小的文件才会被处理,压缩率=压缩大小/原始大小,如果压缩后和原始文件大小没有太大区别,就不用压缩
deleteOriginalAssets: false, //是否删除原文件,最好不删除,服务器会自动优先返回同名的.gzip资源如果找不到还可以拿原始文件
}),
new CompressionWebpackPlugin({
filename: '[path][base].gz', //压缩后的文件名
algorithm: 'gzip', //压缩格式 有gzip、brotliCompress
test: /\.(js|css|svg)$/,
threshold: 10240, // 只处理比这个值大的资源,按字节算
minRatio: 0.8, //只有压缩率比这个值小的文件才会被处理,压缩率=压缩大小/原始大小,如果压缩后和原始文件大小没有太大区别,就不用压缩
deleteOriginalAssets: false, //是否删除原文件,最好不删除,服务器会自动优先返回同名的.gzip资源如果找不到还可以拿原始文件
}),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin(
Object.assign(
@ -805,19 +808,19 @@ module.exports = function (webpackEnv) {
},
isEnvProduction
? {
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}
: undefined
)
),
@ -825,10 +828,10 @@ module.exports = function (webpackEnv) {
// a network request.
// https://github.com/facebook/create-react-app/issues/5358
isEnvProduction &&
shouldInlineRuntimeChunk &&
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [
/runtime-.+[.]js/,
]),
shouldInlineRuntimeChunk &&
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [
/runtime-.+[.]js/,
]),
// Makes some environment variables available in index.html.
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
@ -847,22 +850,22 @@ module.exports = function (webpackEnv) {
// Experimental hot reloading for React .
// https://github.com/facebook/react/tree/main/packages/react-refresh
isEnvDevelopment &&
shouldUseReactRefresh &&
new ReactRefreshWebpackPlugin({
overlay: false,
}),
shouldUseReactRefresh &&
new ReactRefreshWebpackPlugin({
overlay: false,
}),
// Watcher doesn't work well if you mistype casing in a path so we use
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebook/create-react-app/issues/240
isEnvDevelopment && new CaseSensitivePathsPlugin(),
isEnvProduction &&
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename:
'static/css/[name].[contenthash:8].chunk.css',
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename:
'static/css/[name].[contenthash:8].chunk.css',
}),
// Generate an asset manifest file with the following content:
// - "files" key: Mapping of all asset filenames to their corresponding
// output file so that tools can pick it up without having to parse
@ -899,136 +902,123 @@ module.exports = function (webpackEnv) {
// Generate a service worker script that will precache, and keep up to date,
// the HTML & assets that are part of the webpack build.
isEnvProduction &&
fs.existsSync(swSrc) &&
new WorkboxWebpackPlugin.InjectManifest({
swSrc,
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
// Bump up the default maximum size (2mb) that's precached,
// to make lazy-loading failure scenarios less likely.
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
}),
fs.existsSync(swSrc) &&
new WorkboxWebpackPlugin.InjectManifest({
swSrc,
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
// Bump up the default maximum size (2mb) that's precached,
// to make lazy-loading failure scenarios less likely.
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
}),
// TypeScript type checking
useTypeScript &&
new ForkTsCheckerWebpackPlugin({
async: isEnvDevelopment,
typescript: {
typescriptPath: resolve.sync('typescript', {
basedir: paths.appNodeModules,
}),
// configOverwrite: {
// compilerOptions: {
// sourceMap: isEnvProduction
// ? shouldUseSourceMap
// : isEnvDevelopment,
// skipLibCheck: true,
// inlineSourceMap: false,
// declarationMap: false,
// noEmit: true,
// incremental: true,
// tsBuildInfoFile: paths.appTsBuildInfoFile,
// },
// },
configFile: paths.appTsConfig,
context: paths.appRootPath,
diagnosticOptions: {
syntactic: true,
},
mode: 'write-references',
// profile: true,
memoryLimit,
},
issue: {
// This one is specifically to match during CI tests,
// as micromatch doesn't match
// '../cra-template-typescript/template/src/App.tsx'
// otherwise.
include: [
{ file: '../**/app/**/*.{ts,tsx}' },
{ file: '**/app/**/*.{ts,tsx}' },
{ file: '../**/app/**/*.*.{ts,tsx}' },
{ file: '**/app/**/*.*.{ts,tsx}' },
{ file: '../**/src/**/*.{ts,tsx}' },
{ file: '**/src/**/*.{ts,tsx}' },
{ file: '../**/src/**/*.*.{ts,tsx}' },
{ file: '**/src/**/*.*.{ts,tsx}' },
],
exclude: [
{ file: '**/src/**/__tests__/**' },
{ file: '**/src/**/?(*.){spec|test}.*' },
{ file: '**/src/setupProxy.*' },
{ file: '**/src/setupTests.*' },
],
},
logger: {
log: (message) => console.log(message),
error: (message) => console.error(message),
},
}),
!disableESLintPlugin &&
new ESLintPlugin({
// Plugin options
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
formatter: require.resolve(
'react-dev-utils/eslintFormatter'
),
eslintPath: require.resolve('eslint'),
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
context: paths.appSrc,
cache: true,
cacheLocation: path.resolve(
paths.appNodeModules,
'.cache/.eslintcache'
),
// ESLint class options
cwd: paths.appPath,
resolvePluginsRelativeTo: __dirname,
baseConfig: {
extends: [
require.resolve('eslint-config-react-app/base'),
],
rules: {
...(!hasJsxRuntime && {
'react/react-in-jsx-scope': 'error',
new ForkTsCheckerWebpackPlugin({
async: isEnvDevelopment,
typescript: {
typescriptPath: resolve.sync('typescript', {
basedir: paths.appNodeModules,
}),
configFile: paths.appTsConfig,
context: paths.appRootPath,
diagnosticOptions: {
syntactic: true,
},
mode: 'write-references',
// profile: true,
memoryLimit,
},
},
}),
issue: {
// This one is specifically to match during CI tests,
// as micromatch doesn't match
// '../cra-template-typescript/template/src/App.tsx'
// otherwise.
include: [
{ file: '../**/app/**/*.{ts,tsx}' },
{ file: '**/app/**/*.{ts,tsx}' },
{ file: '../**/app/**/*.*.{ts,tsx}' },
{ file: '**/app/**/*.*.{ts,tsx}' },
{ file: '../**/src/**/*.{ts,tsx}' },
{ file: '**/src/**/*.{ts,tsx}' },
{ file: '../**/src/**/*.*.{ts,tsx}' },
{ file: '**/src/**/*.*.{ts,tsx}' },
],
exclude: [
{ file: '**/src/**/__tests__/**' },
{ file: '**/src/**/?(*.){spec|test}.*' },
{ file: '**/src/setupProxy.*' },
{ file: '**/src/setupTests.*' },
],
},
logger: {
log: (message) => console.log(message),
error: (message) => console.error(message),
},
}),
!disableESLintPlugin &&
new ESLintPlugin({
// Plugin options
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
formatter: require.resolve(
'react-dev-utils/eslintFormatter'
),
eslintPath: require.resolve('eslint'),
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
context: paths.appSrc,
cache: true,
cacheLocation: path.resolve(
paths.appNodeModules,
'.cache/.eslintcache'
),
// ESLint class options
cwd: paths.appPath,
resolvePluginsRelativeTo: __dirname,
baseConfig: {
extends: [
require.resolve('eslint-config-react-app/base'),
],
rules: {
...(!hasJsxRuntime && {
'react/react-in-jsx-scope': 'error',
}),
},
},
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
shouldAnalyze &&
new BundleAnalyzerPlugin({
// 可以是`server``static`或`disabled`。
// 在`server`模式下分析器将启动HTTP服务器来显示软件包报告。
// 在“静态”模式下会生成带有报告的单个HTML文件。
// 在`disabled`模式下,你可以使用这个插件来将`generateStatsFile`设置为`true`来生成Webpack Stats JSON文件。
analyzerMode: 'server',
// 将在“服务器”模式下使用的主机启动HTTP服务器。
analyzerHost: '127.0.0.1',
// 将在“服务器”模式下使用的端口启动HTTP服务器。
analyzerPort: 8888,
// 路径捆绑,将在`static`模式下生成的报告文件。
// 相对于捆绑输出目录。
reportFilename: 'report.html',
// 模块大小默认显示在报告中。
// 应该是`stat``parsed`或者`gzip`中的一个。
// 有关更多信息,请参见“定义”一节。
defaultSizes: 'parsed',
// 在默认浏览器中自动打开报告
openAnalyzer: true,
// 如果为true则Webpack Stats JSON文件将在bundle输出目录中生成
generateStatsFile: false,
// 如果`generateStatsFile`为`true`将会生成Webpack Stats JSON文件的名字。
// 相对于捆绑输出目录。
statsFilename: 'stats.json',
// stats.toJson方法的选项。
// 例如,您可以使用`sourcefalse`选项排除统计文件中模块的来源。
// 在这里查看更多选项https //github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
statsOptions: null,
logLevel: 'info',
}),
new BundleAnalyzerPlugin({
// 可以是`server``static`或`disabled`。
// 在`server`模式下分析器将启动HTTP服务器来显示软件包报告。
// 在“静态”模式下会生成带有报告的单个HTML文件。
// 在`disabled`模式下,你可以使用这个插件来将`generateStatsFile`设置为`true`来生成Webpack Stats JSON文件。
analyzerMode: 'server',
// 将在“服务器”模式下使用的主机启动HTTP服务器。
analyzerHost: '127.0.0.1',
// 将在“服务器”模式下使用的端口启动HTTP服务器。
analyzerPort: 8888,
// 路径捆绑,将在`static`模式下生成的报告文件。
// 相对于捆绑输出目录。
reportFilename: 'report.html',
// 模块大小默认显示在报告中。
// 应该是`stat``parsed`或者`gzip`中的一个。
// 有关更多信息,请参见“定义”一节。
defaultSizes: 'parsed',
// 在默认浏览器中自动打开报告
openAnalyzer: true,
// 如果为true则Webpack Stats JSON文件将在bundle输出目录中生成
generateStatsFile: false,
// 如果`generateStatsFile`为`true`将会生成Webpack Stats JSON文件的名字。
// 相对于捆绑输出目录。
statsFilename: 'stats.json',
// stats.toJson方法的选项。
// 例如,您可以使用`sourcefalse`选项排除统计文件中模块的来源。
// 在这里查看更多选项https //github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
statsOptions: null,
logLevel: 'info',
}),
].filter(Boolean),
// Turn off performance processing because we utilize
// our own hints via the FileSizeReporter
@ -1039,7 +1029,6 @@ module.exports = function (webpackEnv) {
react: 'React',
'react-dom': 'ReactDOM',
'@wangeditor/editor': 'wangEditor',
// '@wangeditor/basic-modules': 'WangEditorBasicModules', 这里跑起来初始化会有个BUG先不弄了
'@fingerprintjs/fingerprintjs': 'FingerprintJS',
'bn.js': 'BN',
},

View File

@ -31,14 +31,7 @@ async function build(cmd) {
(0, makeRouter_1.default)({ subdir }, mode === 'development');
// makeDependency 放到npm install之后做一次
// makeDep('');
//ts类型检查 waring 还是error,
//主要web受影响error级别的话 控制台和网页都报错warning级别的话 控制台报错
// development/staging/production
const errorLevel = cmd.check !== 'error';
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build ${target} environment:${mode} ${['development'].includes(mode) ? `devMode:${devMode}` : ''} ${['mp', 'wechatMp'].includes(target) &&
['development'].includes(mode)
? `split:${!!cmd.split}`
: ''}`)}`);
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build ${target} environment:${mode} ${['development'].includes(mode) ? `devMode:${devMode}` : ''}`)}`);
if (['mp', 'wechatMp'].includes(target)) {
const mpFileMap = {
production: 'build-mp.js',
@ -50,11 +43,9 @@ async function build(cmd) {
`NODE_TARGET=${target}`,
`OAK_DEV_MODE=${devMode}`,
`SUB_DIR_NAME=${subdir}`,
`TSC_COMPILE_ON_ERROR=${errorLevel}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`SPLIT=${!!cmd.split}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`,
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
@ -82,7 +73,6 @@ async function build(cmd) {
`NODE_TARGET=${target}`,
`OAK_DEV_MODE=${devMode}`,
`SUB_DIR_NAME=${subdir}`,
`TSC_COMPILE_ON_ERROR=${errorLevel}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,

View File

@ -231,7 +231,7 @@ async function create(dirName, cmd) {
}
// 获取package.json内容
const packageJson = (0, template_1.packageJsonContent)({
name: DEFAULT_PROJECT_NAME,
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
version,
description,
cliName: config_1.CLI_NAME,

View File

@ -62,12 +62,10 @@ commander_1.default
.option('--sourceMap', 'sourceMap')
.option('--analyze', 'analyze')
.option('--prod', 'prod')
.option('--split', 'split')
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-c, --check <level>', 'level')
.option('-p, --port <port>', 'port')
.option('-dm, --devMode <devMode>', 'devMode')
.description('build project of start on demand')
@ -80,7 +78,6 @@ commander_1.default
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-c, --check <level>', 'level')
.option('-p, --platform <platform>', 'platform')
.description('build project of build on demand')
.action(build_1.default);

View File

@ -16,6 +16,7 @@ const sticky_1 = require("@socket.io/sticky");
const socket_io_1 = require("socket.io");
const DATA_SUBSCRIBER_NAMESPACE = '/ds';
const SERVER_SUBSCRIBER_NAMESPACE = process.env.OAK_SSUB_NAMESPACE || '/ssub';
const ExceptionMask = '内部不可知错误';
function concat(...paths) {
return paths.reduce((prev, current) => {
if (current.startsWith('/')) {
@ -72,7 +73,7 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
catch (err) {
console.error(err);
const { request } = ctx;
const exception = err instanceof types_1.OakException ? err : new types_1.OakException('内部不可知错误');
const exception = err instanceof types_1.OakException ? err : new types_1.OakException(serverConfiguration?.internalExceptionMask || ExceptionMask);
const { body } = connector.serializeException(exception, request.headers, request.body);
ctx.response.body = body;
return;

View File

@ -260,6 +260,11 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
],
"staging": [
">0.2%",
"not dead",
"not op_mini all"
]
},
"copyWebpack": []

View File

@ -7,7 +7,7 @@ const webpack = require('webpack');
const chalk = require('chalk');
const fs = require('fs-extra');
const configFactory = require('../config/mp/webpack.config');
const config = configFactory('production');
const config = configFactory('staging');
const paths = require('../config/mp/paths');
const getClientEnvironment = require('../config/mp/env');

View File

@ -47,7 +47,7 @@ const argv = process.argv.slice(2);
const writeStatsJson = argv.indexOf('--stats') !== -1;
// Generate configuration
const config = configFactory('production');
const config = configFactory('staging');
// We require that you explicitly set browsers and do not fall back to
// browserslist defaults.

View File

@ -46,19 +46,11 @@ export default async function build(cmd: any) {
makeRouter({ subdir }, mode === 'development');
// makeDependency 放到npm install之后做一次
// makeDep('');
//ts类型检查 waring 还是error,
//主要web受影响error级别的话 控制台和网页都报错warning级别的话 控制台报错
// development/staging/production
const errorLevel = cmd.check !== 'error';
Success(
`${success(
`build ${target} environment:${mode} ${
['development'].includes(mode) ? `devMode:${devMode}` : ''
} ${
['mp', 'wechatMp'].includes(target) &&
['development'].includes(mode)
? `split:${!!cmd.split}`
: ''
}`
)}`
);
@ -75,11 +67,9 @@ export default async function build(cmd: any) {
`NODE_TARGET=${target}`,
`OAK_DEV_MODE=${devMode}`,
`SUB_DIR_NAME=${subdir}`,
`TSC_COMPILE_ON_ERROR=${errorLevel}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,
`SPLIT=${!!cmd.split}`,
!!cmd.memoryLimit && `MEMORY_LIMIT=${cmd.memoryLimit}`,
`node`,
cmd.memoryLimit && `--max_old_space_size=${cmd.memoryLimit}`,
@ -109,7 +99,6 @@ export default async function build(cmd: any) {
`NODE_TARGET=${target}`,
`OAK_DEV_MODE=${devMode}`,
`SUB_DIR_NAME=${subdir}`,
`TSC_COMPILE_ON_ERROR=${errorLevel}`,
`COMPILE_ANALYZE=${!!cmd.analyze}`,
`GENERATE_SOURCEMAP=${!!cmd.sourcemap}`,
`PROD=${!!cmd.prod}`,

View File

@ -71,12 +71,10 @@ program
.option('--sourceMap', 'sourceMap')
.option('--analyze', 'analyze')
.option('--prod', 'prod')
.option('--split', 'split')
.option('--memoryLimit <memoryLimit>', 'memoryLimit of node')
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-c, --check <level>', 'level')
.option('-p, --port <port>', 'port')
.option('-dm, --devMode <devMode>', 'devMode')
.description('build project of start on demand')
@ -89,7 +87,6 @@ program
.option('-t, --target <target>', 'target')
.option('-m, --mode <mode>', 'mode')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-c, --check <level>', 'level')
.option('-p, --platform <platform>', 'platform')
.description('build project of build on demand')
.action(build);

View File

@ -13,10 +13,11 @@ import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
import { createAdapter } from "@socket.io/cluster-adapter";
import { setupWorker } from "@socket.io/sticky";
import { Server, ServerOptions } from "socket.io";
import { AccessConfiguration, ServerConfiguration } from 'oak-domain/lib/types/Configuration';
import { ServerConfiguration } from 'oak-domain/lib/types/Configuration';
const DATA_SUBSCRIBER_NAMESPACE = '/ds';
const SERVER_SUBSCRIBER_NAMESPACE = process.env.OAK_SSUB_NAMESPACE || '/ssub';
const ExceptionMask = '内部不可知错误';
function concat(...paths: string[]) {
return paths.reduce(
@ -88,7 +89,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
catch (err) {
console.error(err);
const { request } = ctx;
const exception = err instanceof OakException ? err : new OakException('内部不可知错误');
const exception = err instanceof OakException ? err : new OakException(serverConfiguration?.internalExceptionMask || ExceptionMask);
const { body } = connector.serializeException(exception, request.headers, request.body);
ctx.response.body = body;
return;

View File

@ -278,6 +278,11 @@ export function packageJsonContent({
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
],
"staging": [
">0.2%",
"not dead",
"not op_mini all"
]
},
"copyWebpack": []

View File

@ -119,7 +119,7 @@
var tip = document.createElement('div');
var closeBtn = document.createElement('img');
var contentHTML =
'您当前使用的浏览器可能会出现界面显示异常或功能无法正常使用等问题,建议下载使用最新的 360 极速浏览器并切换到极速模式。';
'您当前使用的浏览器可能会出现界面显示异常或功能无法正常使用等问题,建议下载使用谷歌火狐edge等新版本浏览器。';
var handleClickClose = function (event) {
document.body.removeChild(tip);
};