@ray-js/builder-web 0.4.12-beta-1 → 0.5.0

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.
Files changed (2) hide show
  1. package/lib/build.js +20 -8
  2. package/package.json +6 -7
package/lib/build.js CHANGED
@@ -18,7 +18,6 @@ const colors_1 = __importDefault(require("colors"));
18
18
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
19
19
  const detect_port_1 = __importDefault(require("detect-port"));
20
20
  const fs_extra_1 = __importDefault(require("fs-extra"));
21
- const hard_source_webpack_plugin_1 = __importDefault(require("hard-source-webpack-plugin"));
22
21
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
23
22
  const inquirer_1 = __importDefault(require("inquirer"));
24
23
  const path_1 = __importDefault(require("path"));
@@ -48,7 +47,7 @@ function build(options, context) {
48
47
  port: '8088',
49
48
  https: false,
50
49
  }, options);
51
- const { cwd, mode, output, target, analyze, watch, mini, source, port, https } = compileOptions;
50
+ const { cwd, mode, output, target, analyze, watch, mini, source, port } = compileOptions;
52
51
  process.env.NODE_ENV = mode;
53
52
  process.env.PLATFORM = 'web';
54
53
  process.env.REMAX_PLATFORM = 'web';
@@ -62,8 +61,10 @@ function build(options, context) {
62
61
  const config = new webpack_chain_1.default();
63
62
  config.mode(mode);
64
63
  if (isDev) {
65
- const devtool = isDev ? 'cheap-module-eval-source-map' : 'source-map';
66
- config.devtool(devtool);
64
+ config.devtool('cheap-module-source-map');
65
+ config.cache({
66
+ type: 'filesystem',
67
+ });
67
68
  shared_1.log.info(LOG_PREFIX, 'enabled webpack devtool SourceMap '.yellow);
68
69
  }
69
70
  config.context(cwd);
@@ -114,15 +115,27 @@ function build(options, context) {
114
115
  .end();
115
116
  (0, process_css_1.processCss)(config);
116
117
  (0, process_less_1.processLess)(config);
118
+ config.module
119
+ .rule('image-sources')
120
+ .test(/\.(png|jpe?g|gif|svg)$/i)
121
+ .type('asset')
122
+ .parser({
123
+ dataUrlCondition: {
124
+ maxSize: 8 * 1024,
125
+ },
126
+ });
127
+ config.module
128
+ .rule('font-sources')
129
+ .test(/\.(ttf|eot|woff|woff2)$/i)
130
+ .type('asset/resource');
117
131
  config.optimization
118
- .minimize(mini)
132
+ .set('emitOnErrors', watch !== null && watch !== void 0 ? watch : false)
133
+ .minimize(mini !== null && mini !== void 0 ? mini : false)
119
134
  .runtimeChunk({ name: 'runtime' })
120
- .noEmitOnErrors(watch)
121
135
  .splitChunks({
122
136
  chunks: 'all',
123
137
  maxInitialRequests: Infinity,
124
138
  minSize: 0,
125
- name: isDev,
126
139
  cacheGroups: {
127
140
  // 项目内公用的
128
141
  common: {
@@ -151,7 +164,6 @@ function build(options, context) {
151
164
  ]);
152
165
  analyze && config.plugin('bundle-analyzer-plugin').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin);
153
166
  config.plugin('case-sensitive-paths-webpack-plugin').use(case_sensitive_paths_webpack_plugin_1.default);
154
- isDev && config.plugin('hard-source-webpack-plugin').use(hard_source_webpack_plugin_1.default);
155
167
  isProd &&
156
168
  config.plugin('webpack.HashedModuleIdsPlugin').use(webpack_1.default.ids.HashedModuleIdsPlugin, [
157
169
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/builder-web",
3
- "version": "0.4.12-beta-1",
3
+ "version": "0.5.0",
4
4
  "description": "Ray builder for web",
5
5
  "keywords": [
6
6
  "ray"
@@ -21,10 +21,10 @@
21
21
  "watch": "tsc -p ./tsconfig.build.json --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@ray-js/babel-preset-standard": "^0.4.12-beta-1",
25
- "@ray-js/env-loader": "^0.4.12-beta-1",
26
- "@ray-js/shared": "^0.4.12-beta-1",
27
- "@ray-js/types": "^0.4.12-beta-1",
24
+ "@ray-js/babel-preset-standard": "^0.5.0",
25
+ "@ray-js/env-loader": "^0.5.0",
26
+ "@ray-js/shared": "^0.5.0",
27
+ "@ray-js/types": "^0.5.0",
28
28
  "address": "^1.1.2",
29
29
  "autoprefixer": "9.x",
30
30
  "camelcase": "^6.2.1",
@@ -34,7 +34,6 @@
34
34
  "css-loader": "5.x",
35
35
  "detect-port": "^1.3.0",
36
36
  "fs-extra": "^10.0.0",
37
- "hard-source-webpack-plugin": "^0.13.1",
38
37
  "html-webpack-plugin": "4.x",
39
38
  "inquirer": "^8.2.0",
40
39
  "less": "^4.1.1",
@@ -59,6 +58,6 @@
59
58
  "email": "tuyafe@tuya.com"
60
59
  }
61
60
  ],
62
- "gitHead": "5acf68257616900ca67e609e0f7765c6aa1f6efa",
61
+ "gitHead": "5f49ac5a276532472d10aa60ec21c9a5f0b28ce8",
63
62
  "repository": {}
64
63
  }