@jpp-toolkit/rspack-config 0.0.2 → 0.0.3
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/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/create-fivem-rspack-config.ts +14 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { mergeWithRules } from "webpack-merge";
|
|
3
4
|
|
|
@@ -16,13 +17,25 @@ function createFivemRspackConfig(overrides = {}) {
|
|
|
16
17
|
const cwd = overrides.context ?? process.cwd();
|
|
17
18
|
const mode = overrides.mode ?? (process.env.NODE_ENV === "production" ? "production" : "development");
|
|
18
19
|
const isProduction = mode === "production";
|
|
20
|
+
const entries = {};
|
|
21
|
+
for (const name of [
|
|
22
|
+
"client",
|
|
23
|
+
"server",
|
|
24
|
+
"shared"
|
|
25
|
+
]) for (const file of [`src/${name}/index.ts`, `src/${name}.ts`]) {
|
|
26
|
+
const entryPath = path.resolve(cwd, file);
|
|
27
|
+
if (existsSync(entryPath)) {
|
|
28
|
+
entries[name] = entryPath;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
19
32
|
return mergeConfig({
|
|
20
33
|
name: "fivem",
|
|
21
34
|
context: cwd,
|
|
22
35
|
target: "node16",
|
|
23
36
|
devtool: false,
|
|
24
37
|
mode,
|
|
25
|
-
entry:
|
|
38
|
+
entry: entries,
|
|
26
39
|
output: {
|
|
27
40
|
clean: true,
|
|
28
41
|
path: path.resolve(cwd, "dist")
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/merge-config.ts","../src/create-fivem-rspack-config.ts"],"sourcesContent":["import { mergeWithRules } from 'webpack-merge';\n\nexport const mergeConfig = mergeWithRules({\n module: {\n rules: {\n test: 'match',\n use: {\n loader: 'match',\n options: 'merge',\n },\n },\n },\n});\n","import path from 'node:path';\n\nimport type { RspackOptions } from '@rspack/core';\n\nimport { mergeConfig } from './utils/merge-config';\n\nexport function createFivemRspackConfig(overrides: RspackOptions = {}): RspackOptions {\n const cwd = overrides.context ?? process.cwd();\n const mode =\n overrides.mode ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n const isProduction = mode === 'production';\n\n const config: RspackOptions = {\n name: 'fivem',\n\n context: cwd,\n\n target: 'node16',\n devtool: false,\n mode,\n\n entry:
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["entries: Record<string, string>"],"sources":["../src/utils/merge-config.ts","../src/create-fivem-rspack-config.ts"],"sourcesContent":["import { mergeWithRules } from 'webpack-merge';\n\nexport const mergeConfig = mergeWithRules({\n module: {\n rules: {\n test: 'match',\n use: {\n loader: 'match',\n options: 'merge',\n },\n },\n },\n});\n","import { existsSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { RspackOptions } from '@rspack/core';\n\nimport { mergeConfig } from './utils/merge-config';\n\nexport function createFivemRspackConfig(overrides: RspackOptions = {}): RspackOptions {\n const cwd = overrides.context ?? process.cwd();\n const mode =\n overrides.mode ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n const isProduction = mode === 'production';\n\n const entries: Record<string, string> = {};\n\n for (const name of ['client', 'server', 'shared']) {\n for (const file of [`src/${name}/index.ts`, `src/${name}.ts`]) {\n const entryPath = path.resolve(cwd, file);\n if (existsSync(entryPath)) {\n entries[name] = entryPath;\n break;\n }\n }\n }\n\n const config: RspackOptions = {\n name: 'fivem',\n\n context: cwd,\n\n target: 'node16',\n devtool: false,\n mode,\n\n entry: entries,\n\n output: {\n clean: true,\n path: path.resolve(cwd, 'dist'),\n },\n\n optimization: {\n minimize: isProduction,\n },\n\n resolve: {\n extensions: ['.js', '.json', '.wasm', '.ts'],\n extensionAlias: {\n '.js': ['.ts', '.js'],\n '.cjs': ['.cts', '.cjs'],\n '.mjs': ['.mts', '.mjs'],\n },\n tsConfig: path.resolve(cwd, 'tsconfig.json'),\n },\n\n node: {\n global: false,\n __filename: false,\n __dirname: false,\n },\n\n externalsPresets: {\n node: true,\n },\n\n module: {\n rules: [\n {\n test: /\\.(?:ts|cts|mts)$/iu,\n type: 'javascript/auto',\n exclude: [/dist\\//u, /node_modules\\//u],\n loader: 'builtin:swc-loader',\n options: {\n minify: isProduction,\n module: {\n type: 'nodenext',\n },\n jsc: {\n target: 'es2021',\n parser: {\n syntax: 'typescript',\n },\n transform: {\n useDefineForClassFields: true,\n },\n keepClassNames: true,\n externalHelpers: false,\n },\n },\n },\n ],\n },\n\n watchOptions: {\n aggregateTimeout: 200,\n ignored: [\n '**/.git',\n '**/.turbo',\n '**/coverage',\n '**/dist',\n '**/generated',\n '**/old',\n '**/tmp',\n ],\n },\n };\n\n return mergeConfig(config, overrides);\n}\n"],"mappings":";;;;;AAEA,MAAa,cAAc,eAAe,EACtC,QAAQ,EACJ,OAAO;CACH,MAAM;CACN,KAAK;EACD,QAAQ;EACR,SAAS;EACZ;CACJ,EACJ,EACJ,CAAC;;;;ACLF,SAAgB,wBAAwB,YAA2B,EAAE,EAAiB;CAClF,MAAM,MAAM,UAAU,WAAW,QAAQ,KAAK;CAC9C,MAAM,OACF,UAAU,SAAS,QAAQ,IAAI,aAAa,eAAe,eAAe;CAC9E,MAAM,eAAe,SAAS;CAE9B,MAAMA,UAAkC,EAAE;AAE1C,MAAK,MAAM,QAAQ;EAAC;EAAU;EAAU;EAAS,CAC7C,MAAK,MAAM,QAAQ,CAAC,OAAO,KAAK,YAAY,OAAO,KAAK,KAAK,EAAE;EAC3D,MAAM,YAAY,KAAK,QAAQ,KAAK,KAAK;AACzC,MAAI,WAAW,UAAU,EAAE;AACvB,WAAQ,QAAQ;AAChB;;;AAuFZ,QAAO,YAlFuB;EAC1B,MAAM;EAEN,SAAS;EAET,QAAQ;EACR,SAAS;EACT;EAEA,OAAO;EAEP,QAAQ;GACJ,OAAO;GACP,MAAM,KAAK,QAAQ,KAAK,OAAO;GAClC;EAED,cAAc,EACV,UAAU,cACb;EAED,SAAS;GACL,YAAY;IAAC;IAAO;IAAS;IAAS;IAAM;GAC5C,gBAAgB;IACZ,OAAO,CAAC,OAAO,MAAM;IACrB,QAAQ,CAAC,QAAQ,OAAO;IACxB,QAAQ,CAAC,QAAQ,OAAO;IAC3B;GACD,UAAU,KAAK,QAAQ,KAAK,gBAAgB;GAC/C;EAED,MAAM;GACF,QAAQ;GACR,YAAY;GACZ,WAAW;GACd;EAED,kBAAkB,EACd,MAAM,MACT;EAED,QAAQ,EACJ,OAAO,CACH;GACI,MAAM;GACN,MAAM;GACN,SAAS,CAAC,WAAW,kBAAkB;GACvC,QAAQ;GACR,SAAS;IACL,QAAQ;IACR,QAAQ,EACJ,MAAM,YACT;IACD,KAAK;KACD,QAAQ;KACR,QAAQ,EACJ,QAAQ,cACX;KACD,WAAW,EACP,yBAAyB,MAC5B;KACD,gBAAgB;KAChB,iBAAiB;KACpB;IACJ;GACJ,CACJ,EACJ;EAED,cAAc;GACV,kBAAkB;GAClB,SAAS;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACH;GACJ;EACJ,EAE0B,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
|
|
3
4
|
import type { RspackOptions } from '@rspack/core';
|
|
@@ -10,6 +11,18 @@ export function createFivemRspackConfig(overrides: RspackOptions = {}): RspackOp
|
|
|
10
11
|
overrides.mode ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');
|
|
11
12
|
const isProduction = mode === 'production';
|
|
12
13
|
|
|
14
|
+
const entries: Record<string, string> = {};
|
|
15
|
+
|
|
16
|
+
for (const name of ['client', 'server', 'shared']) {
|
|
17
|
+
for (const file of [`src/${name}/index.ts`, `src/${name}.ts`]) {
|
|
18
|
+
const entryPath = path.resolve(cwd, file);
|
|
19
|
+
if (existsSync(entryPath)) {
|
|
20
|
+
entries[name] = entryPath;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
const config: RspackOptions = {
|
|
14
27
|
name: 'fivem',
|
|
15
28
|
|
|
@@ -19,7 +32,7 @@ export function createFivemRspackConfig(overrides: RspackOptions = {}): RspackOp
|
|
|
19
32
|
devtool: false,
|
|
20
33
|
mode,
|
|
21
34
|
|
|
22
|
-
entry:
|
|
35
|
+
entry: entries,
|
|
23
36
|
|
|
24
37
|
output: {
|
|
25
38
|
clean: true,
|