@vyriy/webpack-config 0.4.9 → 0.4.10

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,6 +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
+ - webpack-dev-server uses shared CORS headers for local cross-origin bundle consumption
150
151
  - CSS is extracted with `MiniCssExtractPlugin` in production and development
151
152
  - development builds enable React refresh with `ReactRefreshWebpackPlugin`
152
153
 
package/csr.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
2
2
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
3
3
  import { path } from '@vyriy/path';
4
+ import { devServer } from './dev-server.js';
4
5
  import { mode } from './mode.js';
5
6
  import { optimization } from './optimization.js';
6
7
  import { performance } from './performance.js';
@@ -12,6 +13,7 @@ export const csr = (entry, output, transform) => {
12
13
  const base = {
13
14
  context: path(),
14
15
  devtool: false,
16
+ devServer: devServer(),
15
17
  mode: webpackMode,
16
18
  target: isProduction ? 'browserslist' : 'web',
17
19
  entry,
@@ -0,0 +1,7 @@
1
+ import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';
2
+ export declare const devServerCorsHeaders: {
3
+ readonly 'Access-Control-Allow-Headers': "*";
4
+ readonly 'Access-Control-Allow-Methods': "GET, HEAD, OPTIONS";
5
+ readonly 'Access-Control-Allow-Origin': "*";
6
+ };
7
+ export declare const devServer: (options?: DevServerConfiguration) => DevServerConfiguration;
package/dev-server.js ADDED
@@ -0,0 +1,19 @@
1
+ export const devServerCorsHeaders = {
2
+ 'Access-Control-Allow-Headers': '*',
3
+ 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
4
+ 'Access-Control-Allow-Origin': '*',
5
+ };
6
+ const isHeadersRecord = (headers) => {
7
+ return Boolean(headers) && !Array.isArray(headers) && typeof headers === 'object';
8
+ };
9
+ export const devServer = (options = {}) => {
10
+ return {
11
+ ...options,
12
+ headers: isHeadersRecord(options.headers)
13
+ ? {
14
+ ...devServerCorsHeaders,
15
+ ...options.headers,
16
+ }
17
+ : (options.headers ?? devServerCorsHeaders),
18
+ };
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyriy/webpack-config",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Shared Webpack config for Vyriy projects",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,6 +29,16 @@
29
29
  "import": "./csr.js",
30
30
  "default": "./csr.js"
31
31
  },
32
+ "./dev-server": {
33
+ "types": "./dev-server.d.ts",
34
+ "import": "./dev-server.js",
35
+ "default": "./dev-server.js"
36
+ },
37
+ "./dev-server.js": {
38
+ "types": "./dev-server.d.ts",
39
+ "import": "./dev-server.js",
40
+ "default": "./dev-server.js"
41
+ },
32
42
  "./external": {
33
43
  "types": "./external.d.ts",
34
44
  "import": "./external.js",
@@ -149,9 +159,9 @@
149
159
  "@babel/register": "^7.29.7",
150
160
  "@babel/runtime": "^7.29.7",
151
161
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
152
- "@vyriy/env": "0.4.9",
153
- "@vyriy/html": "0.4.9",
154
- "@vyriy/path": "0.4.9",
162
+ "@vyriy/env": "0.4.10",
163
+ "@vyriy/html": "0.4.10",
164
+ "@vyriy/path": "0.4.10",
155
165
  "babel-loader": "^10.1.1",
156
166
  "css-loader": "^7.1.4",
157
167
  "cssnano": "^8.0.1",