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