@umijs/plugins 4.0.0-rc.5 → 4.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,40 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const child_process_1 = require("child_process");
27
- const path = __importStar(require("path"));
3
+ const plugin_utils_1 = require("umi/plugin-utils");
4
+ const path_1 = require("path");
28
5
  exports.default = (api) => {
29
- api.describe({ key: 'tailwindcss' });
6
+ api.describe({
7
+ key: 'tailwindcss',
8
+ config: {
9
+ schema(Joi) {
10
+ return Joi.object();
11
+ },
12
+ },
13
+ enableBy: api.EnableBy.config,
14
+ });
15
+ let tailwind = null;
16
+ const outputPath = 'plugin-tailwindcss/tailwind.css';
30
17
  api.onStart(() => {
31
- const inputPath = path.resolve(api.cwd, 'tailwind.css');
32
- const generatedPath = path.resolve(api.paths.absTmpPath, 'tailwind.css');
33
- const binPath = path.resolve(api.cwd, 'node_modules/.bin/tailwind');
18
+ const inputPath = (0, path_1.join)(api.cwd, 'tailwind.css');
19
+ const generatedPath = (0, path_1.join)(api.paths.absTmpPath, outputPath);
20
+ const binPath = (0, path_1.join)(api.cwd, 'node_modules/.bin/tailwind');
34
21
  /** 透过子进程建立 tailwindcss 服务,将生成的 css 写入 generatedPath */
35
- const tailwind = (0, child_process_1.exec)(`${binPath} -i ${inputPath} -o ${generatedPath} --watch`, { cwd: api.cwd });
22
+ tailwind = (0, plugin_utils_1.crossSpawn)(`${binPath}`, [
23
+ '-i',
24
+ inputPath,
25
+ '-o',
26
+ generatedPath,
27
+ api.env === 'development' ? '--watch' : '',
28
+ ], {
29
+ stdio: 'inherit',
30
+ });
36
31
  tailwind.on('error', (m) => {
37
32
  api.logger.error('tailwindcss service encounter an error: ' + m);
38
33
  });
39
- /** 将生成的 css 文件加入到 import 中 */
40
- api.addEntryImports(() => [{ source: generatedPath }]);
34
+ });
35
+ /** 将生成的 css 文件加入到 import 中 */
36
+ api.addEntryImports(() => {
37
+ const generatedPath = (0, plugin_utils_1.winPath)((0, path_1.join)(api.paths.absTmpPath, outputPath));
38
+ return [{ source: generatedPath }];
41
39
  });
42
40
  };
@@ -163,9 +163,9 @@ export const getLocale = () => {
163
163
  // please clear localStorage if you change the baseSeparator config
164
164
  // because changing will break the app
165
165
  const lang =
166
- typeof localStorage !== 'undefined' && useLocalStorage
167
- ? window.localStorage.getItem('umi_locale')
168
- : '';
166
+ navigator.cookieEnabled && typeof localStorage !== 'undefined' && useLocalStorage
167
+ ? window.localStorage.getItem('umi_locale')
168
+ : '';
169
169
  // support baseNavigator, default true
170
170
  let browserLang;
171
171
  {{#BaseNavigator}}
@@ -207,9 +207,9 @@ export const setLocale = (lang: string, realReload: boolean = true) => {
207
207
 
208
208
  const updater = () => {
209
209
  if (getLocale() !== lang) {
210
- if (typeof window.localStorage !== 'undefined' && useLocalStorage) {
211
- window.localStorage.setItem('umi_locale', lang || '');
212
- }
210
+ if (navigator.cookieEnabled && typeof window.localStorage !== 'undefined' && useLocalStorage) {
211
+ window.localStorage.setItem('umi_locale', lang || '');
212
+ }
213
213
  setIntl(lang);
214
214
  if (realReload) {
215
215
  window.location.reload();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-rc.5",
3
+ "version": "4.0.0-rc.6",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -23,11 +23,10 @@
23
23
  "dependencies": {
24
24
  "@ahooksjs/use-request": "^2.0.0",
25
25
  "@ant-design/icons": "^4.7.0",
26
- "@ant-design/pro-layout": "^7.0.1-beta.2",
27
- "@umijs/bundler-utils": "4.0.0-rc.5",
28
- "antd": "^4.18.9",
26
+ "@ant-design/pro-layout": "^7.0.1-beta.3",
27
+ "@umijs/bundler-utils": "4.0.0-rc.6",
29
28
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
- "axios": "^0.26.0",
29
+ "axios": "^0.26.1",
31
30
  "babel-plugin-import": "^1.13.3",
32
31
  "dayjs": "^1.10.8",
33
32
  "dva-core": "^2.0.4",
@@ -42,7 +41,7 @@
42
41
  "warning": "^4.0.3"
43
42
  },
44
43
  "devDependencies": {
45
- "umi": "4.0.0-rc.5"
44
+ "umi": "4.0.0-rc.6"
46
45
  },
47
46
  "publishConfig": {
48
47
  "access": "public"