Commit e245efe0 authored by 陈小聪's avatar 陈小聪 Committed by 陈帅

change environment variables pro only (#3951)

* change environment variables pro only

* change notes
parent 23d00abb
......@@ -10,7 +10,7 @@ module.exports = {
jasmine: true,
},
globals: {
APP_TYPE: true,
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
page: true,
},
rules: {
......
......@@ -6,7 +6,8 @@ import defaultSettings from '../src/defaultSettings';
import slash from 'slash2';
const { pwa, primaryColor } = defaultSettings;
const { APP_TYPE, TEST } = process.env;
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST } = process.env;
const plugins = [
[
......@@ -48,8 +49,8 @@ const plugins = [
];
// 针对 preview.pro.ant.design 的 GA 统计代码
// 业务上不需要这个
if (APP_TYPE === 'site') {
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
plugins.push([
'umi-plugin-ga',
{
......@@ -62,7 +63,8 @@ export default {
// add for transfer to umi
plugins,
define: {
APP_TYPE: APP_TYPE || '',
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
},
treeShaking: true,
targets: {
......
......@@ -24,8 +24,11 @@ function getModulePackageName(module) {
}
export default config => {
// pro 和 开发环境再添加这个插件
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (
process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
process.env.NODE_ENV !== 'production'
) {
// 将所有 less 合并为一个供 themePlugin使用
const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
const stylesDir = path.join(__dirname, '../src/');
......
......@@ -2,6 +2,6 @@ module.exports = {
testURL: 'http://localhost:8000',
preset: 'jest-puppeteer',
globals: {
APP_TYPE: false,
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
},
};
......@@ -23,7 +23,7 @@
"lint:prettier": "check-prettier lint",
"lint:style": "stylelint 'src/**/*.less' --syntax less",
"prettier": "node ./scripts/prettier.js",
"start": "cross-env APP_TYPE=site umi dev",
"start": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site umi dev",
"start:no-mock": "cross-env MOCK=none umi dev",
"test": "umi test",
"test:all": "node ./tests/run-tests.js",
......
......@@ -90,7 +90,11 @@ class BasicLayout extends React.Component {
renderSettingDrawer = () => {
// Do not render SettingDrawer in production
// unless it is deployed in preview.pro.ant.design as demo
if (process.env.NODE_ENV === 'production' && APP_TYPE !== 'site') {
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (
process.env.NODE_ENV === 'production' &&
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION !== 'site'
) {
return null;
}
return <SettingDrawer />;
......
......@@ -4,7 +4,8 @@ import defaultSettings from '../defaultSettings';
let lessNodesAppended;
const updateTheme = primaryColor => {
// Don't compile less in production!
if (APP_TYPE !== 'site') {
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION !== 'site') {
return;
}
// Determine if the component is remounted
......
......@@ -13,7 +13,8 @@ export function getAuthority(str) {
if (typeof authority === 'string') {
return [authority];
}
if (!authority && APP_TYPE === 'site') {
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
return ['admin'];
}
return authority;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment