@vyriy/webpack-config 0.4.1 → 0.4.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 +3 -0
- package/babel.js +6 -5
- package/package.json +25 -13
- package/resolve-dependency.d.ts +1 -0
- package/resolve-dependency.js +3 -0
- package/rules.js +7 -6
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ yarn add @vyriy/webpack-config webpack-cli
|
|
|
26
26
|
|
|
27
27
|
The `webpack` package is listed in the install command because the shared config is consumed by Webpack at build time. Add `webpack-cli` only when the consumer project runs Webpack through CLI commands.
|
|
28
28
|
|
|
29
|
+
Build loaders, Babel presets, and Babel plugins used by the shared config are resolved from `@vyriy/webpack-config`. Consumer projects do not need to install `babel-loader`, style loaders, or the shared Babel presets just to use the defaults.
|
|
30
|
+
|
|
29
31
|
## Usage
|
|
30
32
|
|
|
31
33
|
For client bundles:
|
|
@@ -143,6 +145,7 @@ Shared defaults:
|
|
|
143
145
|
|
|
144
146
|
CSR defaults:
|
|
145
147
|
|
|
148
|
+
- loaders and Babel extensions are resolved from this package for workspace and package-manager isolation
|
|
146
149
|
- production builds extract CSS with `MiniCssExtractPlugin`
|
|
147
150
|
- development builds enable React refresh with `ReactRefreshWebpackPlugin`
|
|
148
151
|
|
package/babel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveDependency } from './resolve-dependency.js';
|
|
1
2
|
export const babel = (isSsr = false, isProduction = true) => {
|
|
2
3
|
const isClientDevelopment = !isProduction && !isSsr;
|
|
3
4
|
const envOptions = {
|
|
@@ -8,26 +9,26 @@ export const babel = (isSsr = false, isProduction = true) => {
|
|
|
8
9
|
return {
|
|
9
10
|
presets: [
|
|
10
11
|
[
|
|
11
|
-
'@babel/preset-env',
|
|
12
|
+
resolveDependency('@babel/preset-env'),
|
|
12
13
|
envOptions,
|
|
13
14
|
],
|
|
14
15
|
[
|
|
15
|
-
'@babel/preset-react',
|
|
16
|
+
resolveDependency('@babel/preset-react'),
|
|
16
17
|
{
|
|
17
18
|
runtime: 'automatic',
|
|
18
19
|
development: !isProduction,
|
|
19
20
|
},
|
|
20
21
|
],
|
|
21
|
-
'@babel/preset-typescript',
|
|
22
|
+
resolveDependency('@babel/preset-typescript'),
|
|
22
23
|
],
|
|
23
24
|
plugins: [
|
|
24
25
|
[
|
|
25
|
-
'@babel/plugin-transform-runtime',
|
|
26
|
+
resolveDependency('@babel/plugin-transform-runtime'),
|
|
26
27
|
{
|
|
27
28
|
regenerator: true,
|
|
28
29
|
},
|
|
29
30
|
],
|
|
30
|
-
...(isClientDevelopment ? ['react-refresh/babel'] : []),
|
|
31
|
+
...(isClientDevelopment ? [resolveDependency('react-refresh/babel')] : []),
|
|
31
32
|
],
|
|
32
33
|
};
|
|
33
34
|
};
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyriy/webpack-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Shared Webpack config for Vyriy projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@babel/core": "^7.29.
|
|
8
|
-
"@babel/plugin-transform-runtime": "^7.29.
|
|
9
|
-
"@babel/preset-env": "^7.29.
|
|
10
|
-
"@babel/preset-react": "^7.
|
|
11
|
-
"@babel/preset-typescript": "^7.
|
|
12
|
-
"@babel/register": "^7.29.
|
|
13
|
-
"@babel/runtime": "^7.29.
|
|
7
|
+
"@babel/core": "^7.29.7",
|
|
8
|
+
"@babel/plugin-transform-runtime": "^7.29.7",
|
|
9
|
+
"@babel/preset-env": "^7.29.7",
|
|
10
|
+
"@babel/preset-react": "^7.29.7",
|
|
11
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
12
|
+
"@babel/register": "^7.29.7",
|
|
13
|
+
"@babel/runtime": "^7.29.7",
|
|
14
14
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
|
15
|
-
"@vyriy/env": "0.4.
|
|
16
|
-
"@vyriy/html": "0.4.
|
|
17
|
-
"@vyriy/path": "0.4.
|
|
15
|
+
"@vyriy/env": "0.4.4",
|
|
16
|
+
"@vyriy/html": "0.4.4",
|
|
17
|
+
"@vyriy/path": "0.4.4",
|
|
18
18
|
"babel-loader": "^10.1.1",
|
|
19
19
|
"css-loader": "^7.1.4",
|
|
20
20
|
"cssnano": "^8.0.1",
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"postcss-loader": "^8.2.1",
|
|
26
26
|
"postcss-preset-env": "^11.3.0",
|
|
27
27
|
"react-refresh": "^0.18.0",
|
|
28
|
-
"sass": "^1.
|
|
28
|
+
"sass": "^1.100.0",
|
|
29
29
|
"sass-loader": "^17.0.0",
|
|
30
30
|
"style-loader": "^4.0.0",
|
|
31
31
|
"terser-webpack-plugin": "^5.6.0",
|
|
32
|
-
"webpack": "^5.107.
|
|
32
|
+
"webpack": "^5.107.2",
|
|
33
|
+
"webpack-cli": "^7.0.2",
|
|
34
|
+
"webpack-dev-server": "^5.2.4"
|
|
33
35
|
},
|
|
34
36
|
"agents": "./AGENTS.md",
|
|
35
37
|
"license": "MIT",
|
|
@@ -136,6 +138,16 @@
|
|
|
136
138
|
"import": "./postcss.js",
|
|
137
139
|
"default": "./postcss.js"
|
|
138
140
|
},
|
|
141
|
+
"./resolve-dependency": {
|
|
142
|
+
"types": "./resolve-dependency.d.ts",
|
|
143
|
+
"import": "./resolve-dependency.js",
|
|
144
|
+
"default": "./resolve-dependency.js"
|
|
145
|
+
},
|
|
146
|
+
"./resolve-dependency.js": {
|
|
147
|
+
"types": "./resolve-dependency.d.ts",
|
|
148
|
+
"import": "./resolve-dependency.js",
|
|
149
|
+
"default": "./resolve-dependency.js"
|
|
150
|
+
},
|
|
139
151
|
"./resolve": {
|
|
140
152
|
"types": "./resolve.d.ts",
|
|
141
153
|
"import": "./resolve.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveDependency: (request: string) => string;
|
package/rules.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
2
|
import { babel } from './babel.js';
|
|
3
3
|
import { postcss } from './postcss.js';
|
|
4
|
+
import { resolveDependency } from './resolve-dependency.js';
|
|
4
5
|
export const SCRIPT_TEST = /\.(mjs|cjs|js|jsx|mts|cts|ts|tsx)$/;
|
|
5
6
|
export const STYLE_TEST = /\.(css|scss|sass)$/;
|
|
6
7
|
export const rules = (isSsr = false, isProduction = true) => [
|
|
@@ -8,24 +9,24 @@ export const rules = (isSsr = false, isProduction = true) => [
|
|
|
8
9
|
test: SCRIPT_TEST,
|
|
9
10
|
exclude: /node_modules/,
|
|
10
11
|
use: {
|
|
11
|
-
loader: 'babel-loader',
|
|
12
|
+
loader: resolveDependency('babel-loader'),
|
|
12
13
|
options: babel(isSsr, isProduction),
|
|
13
14
|
},
|
|
14
15
|
},
|
|
15
16
|
{
|
|
16
17
|
test: STYLE_TEST,
|
|
17
18
|
use: isSsr
|
|
18
|
-
? ['null-loader']
|
|
19
|
+
? [resolveDependency('null-loader')]
|
|
19
20
|
: [
|
|
20
|
-
isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
21
|
-
'css-loader',
|
|
21
|
+
isProduction ? MiniCssExtractPlugin.loader : resolveDependency('style-loader'),
|
|
22
|
+
resolveDependency('css-loader'),
|
|
22
23
|
{
|
|
23
|
-
loader: 'postcss-loader',
|
|
24
|
+
loader: resolveDependency('postcss-loader'),
|
|
24
25
|
options: {
|
|
25
26
|
postcssOptions: postcss(),
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
|
-
'sass-loader',
|
|
29
|
+
resolveDependency('sass-loader'),
|
|
29
30
|
],
|
|
30
31
|
},
|
|
31
32
|
];
|