@lynx-js/css-extract-webpack-plugin 0.6.2 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lynx-js/css-extract-webpack-plugin
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Avoid generating `.css.hot-update.json` when HMR is disabled. ([#1811](https://github.com/lynx-family/lynx-stack/pull/1811))
8
+
9
+ ## 0.6.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Supports `@lynx-js/template-webpack-plugin` 0.9.0. ([#1705](https://github.com/lynx-family/lynx-stack/pull/1705))
14
+
3
15
  ## 0.6.2
4
16
 
5
17
  ### Patch Changes
@@ -79,6 +79,18 @@ class CssExtractRspackPlugin {
79
79
  }
80
80
  export { CssExtractRspackPlugin };
81
81
  class CssExtractRspackPluginImpl {
82
+ /**
83
+ * Check if Hot Module Replacement (HMR) is enabled
84
+ * @param compiler - the webpack/rspack compiler
85
+ * @returns true if HMR is enabled, false otherwise
86
+ */
87
+ isHMREnabled(compiler) {
88
+ const hasHMRPlugin = compiler.options.plugins?.some(plugin => plugin && plugin.name === 'HotModuleReplacementPlugin') ?? false;
89
+ const hasDevServerHot = (compiler.options.devServer
90
+ && compiler.options.devServer.hot !== false) ?? false;
91
+ // Return true only if HMR plugin exists or devServer.hot is not false
92
+ return hasHMRPlugin || hasDevServerHot;
93
+ }
82
94
  constructor(compiler, options) {
83
95
  this.options = options;
84
96
  this.name = 'CssExtractRspackPlugin';
@@ -93,8 +105,7 @@ class CssExtractRspackPluginImpl {
93
105
  runtime: options.runtime ?? false,
94
106
  }).apply(compiler);
95
107
  compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
96
- if (compiler.options.mode === 'development'
97
- || process.env['NODE_ENV'] === 'development') {
108
+ if (this.isHMREnabled(compiler)) {
98
109
  const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(
99
110
  // @ts-expect-error Rspack to Webpack Compilation
100
111
  compilation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/css-extract-webpack-plugin",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "This plugin extracts CSS into separate files. It creates a CSS file per JS file which contains CSS.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -44,18 +44,18 @@
44
44
  "mini-css-extract-plugin": "^2.9.4"
45
45
  },
46
46
  "devDependencies": {
47
- "@microsoft/api-extractor": "7.52.10",
48
- "@rspack/core": "1.4.11",
47
+ "@microsoft/api-extractor": "7.52.15",
48
+ "@rspack/core": "1.5.8",
49
49
  "css-loader": "^7.1.2",
50
50
  "sass-loader": "^16.0.5",
51
- "webpack": "^5.101.2",
51
+ "webpack": "^5.101.3",
52
52
  "@lynx-js/css-serializer": "0.1.3",
53
- "@lynx-js/template-webpack-plugin": "0.8.4",
53
+ "@lynx-js/template-webpack-plugin": "0.9.0",
54
54
  "@lynx-js/test-tools": "0.0.0",
55
55
  "@lynx-js/vitest-setup": "0.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@lynx-js/template-webpack-plugin": "^0.8.0"
58
+ "@lynx-js/template-webpack-plugin": "^0.9.0"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=18"