@vyriy/webpack-config 0.4.8 → 0.4.9

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
@@ -147,7 +147,7 @@ Shared defaults:
147
147
  CSR defaults:
148
148
 
149
149
  - loaders and Babel extensions are resolved from this package for workspace and package-manager isolation
150
- - production builds extract CSS with `MiniCssExtractPlugin`
150
+ - CSS is extracted with `MiniCssExtractPlugin` in production and development
151
151
  - development builds enable React refresh with `ReactRefreshWebpackPlugin`
152
152
 
153
153
  HTML plugin defaults:
@@ -186,6 +186,6 @@ const styles = document.createElement('style');
186
186
  styles.textContent = css;
187
187
  ```
188
188
 
189
- This is useful for custom elements that place styles inside a Shadow DOM. When a custom element should use a linked stylesheet instead, use `style({ mode: 'extract' })` and add `MiniCssExtractPlugin` to the Webpack plugins in both production and development. Webpack dev server can serve the extracted CSS from memory, while production emits the same kind of CSS asset to disk.
189
+ This is useful for custom elements that place styles inside a Shadow DOM. CSR builds extract ordinary stylesheet imports by default, so custom elements can also use a linked stylesheet without local rule replacement. Webpack dev server can serve the extracted CSS from memory, while production emits the same kind of CSS asset to disk.
190
190
 
191
191
  See the article with a complete browser and SSR bundling walkthrough: <https://vyriy.dev/examples/vyriy-webpack-config/>.
package/csr.js CHANGED
@@ -17,11 +17,14 @@ export const csr = (entry, output, transform) => {
17
17
  entry,
18
18
  output,
19
19
  module: {
20
- rules: rules(false, isProduction),
20
+ rules: rules(false, isProduction, 'extract'),
21
21
  },
22
22
  optimization: optimization(isProduction),
23
23
  performance,
24
- plugins: isProduction ? [new MiniCssExtractPlugin()] : [new ReactRefreshWebpackPlugin()],
24
+ plugins: [
25
+ new MiniCssExtractPlugin(),
26
+ ...(isProduction ? [] : [new ReactRefreshWebpackPlugin()]),
27
+ ],
25
28
  resolve: resolve(),
26
29
  };
27
30
  return transform ? transform(base) : base;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyriy/webpack-config",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Shared Webpack config for Vyriy projects",
5
5
  "type": "module",
6
6
  "exports": {
@@ -149,9 +149,9 @@
149
149
  "@babel/register": "^7.29.7",
150
150
  "@babel/runtime": "^7.29.7",
151
151
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
152
- "@vyriy/env": "0.4.8",
153
- "@vyriy/html": "0.4.8",
154
- "@vyriy/path": "0.4.8",
152
+ "@vyriy/env": "0.4.9",
153
+ "@vyriy/html": "0.4.9",
154
+ "@vyriy/path": "0.4.9",
155
155
  "babel-loader": "^10.1.1",
156
156
  "css-loader": "^7.1.4",
157
157
  "cssnano": "^8.0.1",
package/rules.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { RuleSetRule } from 'webpack';
2
- import type { WebpackStyleRuleOptions } from './types.js';
2
+ import type { WebpackStyleMode, WebpackStyleRuleOptions } from './types.js';
3
3
  export declare const SCRIPT_TEST: RegExp;
4
4
  export declare const STYLE_TEST: RegExp;
5
5
  export declare const style: ({ mode }?: WebpackStyleRuleOptions) => RuleSetRule;
6
- export declare const rules: (isSsr?: boolean, isProduction?: boolean) => RuleSetRule[];
6
+ export declare const rules: (isSsr?: boolean, isProduction?: boolean, styleMode?: WebpackStyleMode) => RuleSetRule[];
package/rules.js CHANGED
@@ -49,11 +49,14 @@ export const style = ({ mode = 'extract' } = {}) => {
49
49
  ],
50
50
  };
51
51
  };
52
- export const rules = (isSsr = false, isProduction = true) => {
52
+ export const rules = (isSsr = false, isProduction = true, styleMode) => {
53
53
  let mode;
54
54
  if (isSsr) {
55
55
  mode = 'ignore';
56
56
  }
57
+ else if (styleMode) {
58
+ mode = styleMode;
59
+ }
57
60
  else if (isProduction) {
58
61
  mode = 'extract';
59
62
  }