@autobest-ui/scripts 1.0.1 → 1.0.4

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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ module.exports = function(
39
39
  result,
40
40
  appConfig,
41
41
  extendEnv,
42
- { isProd, isServer, isHotServer, isSetCommonAlias }
42
+ { isProd, isServer, isHotServer }
43
43
  ) {
44
44
  // 根据条件,对不同环境的配置进行扩展
45
45
  ......
@@ -1,10 +1,26 @@
1
+ const fs = require('fs');
1
2
  const { getProjectPath } = require('./utils');
2
3
 
4
+ let pkgInfo = {
5
+ name: 'ui',
6
+ version: '1.0.0'
7
+ };
8
+ try {
9
+ const pkgPath = getProjectPath('/package.json');
10
+ const pkgStr = fs.readFileSync(pkgPath);
11
+ pkgInfo = JSON.parse(pkgStr);
12
+ } catch (e) {
13
+ // eslint-disable-next-line no-console
14
+ console.warn('The current project does not have a package.json file or content error!!!');
15
+ }
16
+
3
17
  const configPath = getProjectPath('/config/app.config.js');
4
18
 
5
19
  const config = require(configPath);
6
20
 
7
21
  module.exports = {
22
+ projectName: pkgInfo.name,
23
+ projectVersion: pkgInfo.version,
8
24
  startDefaultPort: 3030,
9
25
  startEntry: '/src/index.tsx',
10
26
  ...config
@@ -77,7 +77,7 @@ function getStyleLoaders({ isProd, isServer, isHotServer, isSass, moduleOption =
77
77
  return result;
78
78
  }
79
79
 
80
- module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCommonAlias }) => {
80
+ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
81
81
  const result = {
82
82
  stats: 'errors-only',
83
83
  // 原始源代码(仅限行)定位到原始代码问题,比source-map 快,但是没有列映射(column mapping)的 source-map
@@ -88,6 +88,17 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
88
88
  output: {
89
89
  publicPath: '/'
90
90
  },
91
+ cache: {
92
+ type: 'filesystem',
93
+ version: `${appConfig.projectName}_${isProd ? '1' : '0'}${isServer ? '1' : '0'}${isHotServer ? '1' : '0'}_${
94
+ appConfig.projectVersion
95
+ }`,
96
+ store: 'pack',
97
+ buildDependencies: {
98
+ defaultWebpack: ['webpack/lib/'],
99
+ config: [__filename]
100
+ }
101
+ },
91
102
  // 配置各种loader
92
103
  module: {
93
104
  // 警告替换为Error
@@ -97,7 +108,15 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
97
108
  oneOf: [
98
109
  {
99
110
  test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
100
- type: 'asset'
111
+ type: 'asset',
112
+ parser: {
113
+ dataUrlCondition: {
114
+ maxSize: 2048
115
+ }
116
+ },
117
+ generator: {
118
+ filename: `static/[name].[contenthash:8].[ext]?v=${extendEnv.version}`
119
+ }
101
120
  },
102
121
  {
103
122
  test: /\.(js|ts|tsx)$/,
@@ -225,8 +244,7 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
225
244
  const extendResult = extendConfig(result, appConfig, extendEnv, {
226
245
  isProd,
227
246
  isServer,
228
- isHotServer,
229
- isSetCommonAlias
247
+ isHotServer
230
248
  });
231
249
  if (!extendResult) {
232
250
  throw Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobest-ui/scripts",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "utils for project tools",
6
6
  "bin": {
@@ -91,5 +91,5 @@
91
91
  "webpack-merge": "5.8.0",
92
92
  "webpack-node-externals": "3.0.0"
93
93
  },
94
- "gitHead": "5350d0e451afedca23971bd5469c6f7320145fae"
94
+ "gitHead": "e21c31cc3b068c08fae9a56ec64ef07ddd0f780a"
95
95
  }
@@ -2,7 +2,7 @@ const { merge } = require('webpack-merge');
2
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3
3
  const webpackCommon = require('../common/webpack.common');
4
4
 
5
- module.exports = (appConfig, extendEnv, { isServer, isHotServer, isSetCommonAlias, isProd }) => {
5
+ module.exports = (appConfig, extendEnv, { isServer, isHotServer, isProd }) => {
6
6
  const result = {
7
7
  plugins: [],
8
8
  module: {
@@ -19,5 +19,5 @@ module.exports = (appConfig, extendEnv, { isServer, isHotServer, isSetCommonAlia
19
19
  );
20
20
  }
21
21
 
22
- return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCommonAlias }), result);
22
+ return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer, isHotServer }), result);
23
23
  };
@@ -8,7 +8,6 @@ module.exports = function (appConfig, extendEnv) {
8
8
  baseConfig(appConfig, extendEnv, {
9
9
  isServer: false,
10
10
  isHotServer: true,
11
- isSetCommonAlias: true,
12
11
  isProd: false
13
12
  }),
14
13
  {
@@ -12,7 +12,6 @@ module.exports = function (appConfig, extendEnv) {
12
12
  baseConfig(appConfig, extendEnv, {
13
13
  isServer: false,
14
14
  isHotServer: false,
15
- isSetCommonAlias: true,
16
15
  isProd: false
17
16
  }),
18
17
  {
@@ -8,7 +8,6 @@ module.exports = function (appConfig, extendEnv) {
8
8
  baseConfig(appConfig, extendEnv, {
9
9
  isServer: true,
10
10
  isHotServer: true,
11
- isSetCommonAlias: true,
12
11
  isProd: false
13
12
  }),
14
13
  {
@@ -5,14 +5,11 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
5
5
  const { getProjectPath } = require('../common/utils');
6
6
  const baseConfig = require('./webpack.base');
7
7
 
8
- const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
9
-
10
8
  module.exports = function (appConfig, extendEnv) {
11
9
  return merge(
12
10
  baseConfig(appConfig, extendEnv, {
13
11
  isServer: false,
14
12
  isHotServer: false,
15
- isSetCommonAlias: isCommonBuild,
16
13
  isProd: true
17
14
  }),
18
15
  {
@@ -3,14 +3,11 @@ const { merge } = require('webpack-merge');
3
3
  const { getProjectPath } = require('../common/utils');
4
4
  const baseConfig = require('./webpack.base');
5
5
 
6
- const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
7
-
8
6
  module.exports = function (appConfig, extendEnv) {
9
7
  return merge(
10
8
  baseConfig(appConfig, extendEnv, {
11
9
  isServer: true,
12
10
  isHotServer: false,
13
- isSetCommonAlias: isCommonBuild,
14
11
  isProd: true
15
12
  }),
16
13
  {