@jpp-toolkit/rspack-config 0.0.77 → 0.0.79
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.d.mts +0 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import rspack
|
|
3
|
+
import rspack, { rspack as rspack$1 } from "@rspack/core";
|
|
4
4
|
import { RunScriptWebpackPlugin } from "run-script-webpack-plugin";
|
|
5
5
|
import nodeExternals from "webpack-node-externals";
|
|
6
6
|
import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh";
|
|
@@ -85,7 +85,7 @@ const basePreset = (options, context) => ({
|
|
|
85
85
|
aggregateTimeout: 200,
|
|
86
86
|
ignored: options.watchIgnored
|
|
87
87
|
},
|
|
88
|
-
plugins: [new rspack.EnvironmentPlugin(options.envVariables)]
|
|
88
|
+
plugins: [new rspack$1.EnvironmentPlugin(options.envVariables)]
|
|
89
89
|
});
|
|
90
90
|
//#endregion
|
|
91
91
|
//#region src/presets/node-preset.ts
|
|
@@ -107,7 +107,7 @@ const nodePreset = (options, context) => ({
|
|
|
107
107
|
options: { env: { targets: `node ${options.nodeVersion}` } }
|
|
108
108
|
}] },
|
|
109
109
|
devServer: { devMiddleware: { writeToDisk: true } },
|
|
110
|
-
plugins: [new rspack.EnvironmentPlugin(options.envVariables), context.isServeMode && new RunScriptWebpackPlugin({
|
|
110
|
+
plugins: [new rspack$1.EnvironmentPlugin(options.envVariables), context.isServeMode && new RunScriptWebpackPlugin({
|
|
111
111
|
name: "main.js",
|
|
112
112
|
autoRestart: false
|
|
113
113
|
})]
|
|
@@ -123,7 +123,7 @@ const fivemScriptPreset = (options, context) => ({
|
|
|
123
123
|
devtool: false,
|
|
124
124
|
externals: [],
|
|
125
125
|
optimization: { minimize: context.isProduction },
|
|
126
|
-
plugins: [new rspack
|
|
126
|
+
plugins: [new rspack.EnvironmentPlugin(options.envVariables)]
|
|
127
127
|
});
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region src/presets/react-preset.ts
|
|
@@ -223,11 +223,11 @@ const reactPreset = (options, context) => {
|
|
|
223
223
|
},
|
|
224
224
|
experiments: { css: true },
|
|
225
225
|
plugins: [
|
|
226
|
-
new rspack.EnvironmentPlugin({
|
|
226
|
+
new rspack$1.EnvironmentPlugin({
|
|
227
227
|
...options.envVariables,
|
|
228
228
|
PUBLIC_URL: publicUrl.toString()
|
|
229
229
|
}),
|
|
230
|
-
new rspack.HtmlRspackPlugin({
|
|
230
|
+
new rspack$1.HtmlRspackPlugin({
|
|
231
231
|
template: path.resolve(context.cwd, options.htmlTemplateFile),
|
|
232
232
|
minify: context.isProduction
|
|
233
233
|
}),
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["rspack"],"sources":["../src/constants.ts","../src/presets/base-preset.ts","../src/presets/node-preset.ts","../src/presets/fivem-script-preset.ts","../src/presets/react-preset.ts","../src/presets/fivem-ui-preset.ts","../src/utils/find-first-existing-file.ts","../src/utils/merge-config.ts","../src/create-rspack-config.ts"],"sourcesContent":["export const TS_RULE_TEST = /\\.(?:ts|tsx|cts|mts)$/iu;\nexport const ASSET_RULE_TEST = /\\.(?:jpe?g|png|gif|svg|webp|avif|ico|bmp|tiff?|eot|ttf|woff2?)$/iu;\nexport const CSS_RULE_TEST = /\\.css$/iu;\nexport const HASHED_JS_FILENAME_PATTERN = '[name].[contenthash:8].js';\n","import path from 'node:path';\n\nimport type { SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\n\nimport { TS_RULE_TEST } from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nexport type BasePresetOptions = {\n readonly entryFile: string;\n readonly tsconfigFile: string;\n readonly outDir: string;\n readonly envVariables: Record<string, string | undefined>;\n readonly useDecorators: boolean;\n readonly watchIgnored: string[];\n};\n\nexport const getBasePresetDefaultOptions: GetPresetDefaultOptions<BasePresetOptions> = (\n options,\n) => ({\n entryFile: options.entryFile ?? './src/index.js',\n tsconfigFile: options.tsconfigFile ?? 'tsconfig.json',\n outDir: options.outDir ?? 'dist',\n envVariables: options.envVariables ?? {},\n useDecorators: options.useDecorators ?? false,\n watchIgnored: options.watchIgnored ?? [\n '**/.git',\n '**/.turbo',\n '**/coverage',\n '**/dist',\n '**/target',\n '**/generated',\n '**/old',\n '**/tmp',\n ],\n});\n\nexport const basePreset: Preset<BasePresetOptions> = (options, context) => ({\n name: 'base-preset',\n\n context: context.cwd,\n mode: context.isProduction ? 'production' : 'development',\n\n entry: { main: options.entryFile },\n\n output: {\n clean: true,\n path: path.resolve(context.cwd, options.outDir),\n },\n\n resolve: {\n tsConfig: path.resolve(context.cwd, options.tsconfigFile),\n extensions: ['.ts', '...'],\n extensionAlias: {\n '.js': ['.ts', '.js'],\n '.cts': ['.cts', '.js'],\n '.mjs': ['.mts', '.mjs'],\n },\n },\n\n optimization: { minimize: context.isProduction },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n type: 'javascript/auto',\n loader: 'builtin:swc-loader',\n exclude: [/dist\\//u, /node_modules\\//u],\n options: {\n jsc: {\n externalHelpers: false,\n keepClassNames: true,\n parser: {\n syntax: 'typescript',\n decorators: options.useDecorators,\n },\n transform: {\n useDefineForClassFields: true,\n legacyDecorator: options.useDecorators,\n decoratorMetadata: options.useDecorators,\n },\n experimental: {\n cacheRoot: path.resolve(context.cwd, 'node_modules/.cache/swc'),\n },\n },\n } satisfies SwcLoaderOptions,\n },\n ],\n },\n\n cache:\n !context.isProduction ?\n {\n type: 'persistent',\n storage: {\n type: 'filesystem',\n directory: path.resolve(context.cwd, 'node_modules/.cache/rspack'),\n },\n }\n : false,\n\n stats: {\n preset: 'normal',\n errorDetails: true,\n colors: true,\n },\n\n watchOptions: {\n aggregateTimeout: 200,\n ignored: options.watchIgnored,\n },\n\n plugins: [new rspack.EnvironmentPlugin(options.envVariables)],\n});\n","import type { ExternalItem, SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';\nimport nodeExternals from 'webpack-node-externals';\n\nimport { TS_RULE_TEST } from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { BasePresetOptions } from './base-preset';\nimport { getBasePresetDefaultOptions } from './base-preset';\n\nexport type NodePresetOptions = BasePresetOptions & {\n readonly nodeVersion: number;\n};\n\nexport const getNodePresetDefaultOptions: GetPresetDefaultOptions<NodePresetOptions> = (\n options,\n context,\n) => ({\n ...getBasePresetDefaultOptions(options, context),\n nodeVersion: options.nodeVersion ?? 24,\n});\n\nexport const nodePreset: Preset<NodePresetOptions> = (options, context) => ({\n name: 'node-preset',\n\n target: `node${options.nodeVersion}`,\n\n entry: {\n main: [...(context.isServeMode ? ['@rspack/core/hot/poll?100'] : []), options.entryFile],\n },\n\n externalsPresets: { node: true },\n externalsType: 'commonjs',\n externals: [\n nodeExternals(\n context.isServeMode ? { allowlist: ['@rspack/core/hot/poll?100'] } : undefined,\n ) as ExternalItem,\n ],\n\n optimization: { minimize: false },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n loader: 'builtin:swc-loader',\n options: {\n env: { targets: `node ${options.nodeVersion}` },\n } satisfies SwcLoaderOptions,\n },\n ],\n },\n\n devServer: {\n devMiddleware: {\n writeToDisk: true,\n },\n },\n\n plugins: [\n new rspack.EnvironmentPlugin(options.envVariables),\n context.isServeMode && new RunScriptWebpackPlugin({ name: 'main.js', autoRestart: false }),\n ],\n});\n","import rspack from '@rspack/core';\n\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { NodePresetOptions } from './node-preset';\nimport { getNodePresetDefaultOptions } from './node-preset';\n\nexport type FivemScriptPresetOptions = NodePresetOptions;\n\nexport const getFivemScriptPresetDefaultOptions: GetPresetDefaultOptions<\n FivemScriptPresetOptions\n> = (options, context) => ({\n ...getNodePresetDefaultOptions(options, context),\n nodeVersion: options.nodeVersion ?? 16,\n});\n\nexport const fivemScriptPreset: Preset<FivemScriptPresetOptions> = (options, context) => ({\n name: 'fivem-script-preset',\n\n devtool: false,\n\n externals: [],\n\n optimization: { minimize: context.isProduction },\n\n plugins: [new rspack.EnvironmentPlugin(options.envVariables)],\n});\n","import { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';\n\nimport {\n ASSET_RULE_TEST,\n CSS_RULE_TEST,\n HASHED_JS_FILENAME_PATTERN,\n TS_RULE_TEST,\n} from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { BasePresetOptions } from './base-preset';\nimport { getBasePresetDefaultOptions } from './base-preset';\n\nconst require = createRequire(import.meta.url);\n\nexport type ReactPresetOptions = BasePresetOptions & {\n readonly htmlTemplateFile: string;\n readonly browserlist: string;\n readonly publicUrl: string;\n};\n\nexport const getReactPresetDefaultOptions: GetPresetDefaultOptions<ReactPresetOptions> = (\n options,\n context,\n) => ({\n ...getBasePresetDefaultOptions(options, context),\n htmlTemplateFile: options.htmlTemplateFile ?? 'src/index.html',\n browserlist: options.browserlist ?? 'defaults',\n publicUrl: options.publicUrl ?? 'http://localhost:8080/',\n});\n\nexport const reactPreset: Preset<ReactPresetOptions> = (options, context) => {\n const publicUrl = new URL(options.publicUrl);\n if (!publicUrl.pathname.endsWith('/')) publicUrl.pathname += '/';\n\n return {\n name: 'react-preset',\n\n target: `browserslist:${options.browserlist}`,\n\n output: {\n filename: context.isProduction ? HASHED_JS_FILENAME_PATTERN : '[name].js',\n publicPath: publicUrl.toString(),\n },\n\n resolve: {\n extensions: ['.tsx', '.ts', '.jsx', '...'],\n extensionAlias: {\n '.js': ['.tsx', '.ts', '.jsx', '.js'],\n '.cts': ['.ctsx', '.cts', '.cjsx', '.js'],\n '.mjs': ['.mtsx', '.mts', '.mjsx', '.mjs'],\n },\n },\n\n externalsPresets: { web: true },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n loader: 'builtin:swc-loader',\n options: {\n env: { targets: options.browserlist },\n jsc: {\n parser: {\n syntax: 'typescript',\n tsx: true,\n },\n transform: {\n react: {\n runtime: 'automatic',\n throwIfNamespace: true,\n useBuiltins: false,\n development: !context.isProduction,\n refresh: context.isServeMode,\n },\n },\n },\n } satisfies SwcLoaderOptions,\n },\n {\n test: ASSET_RULE_TEST,\n type: 'asset/resource',\n },\n {\n test: CSS_RULE_TEST,\n type: 'css',\n use: [\n {\n loader: require.resolve('postcss-loader'),\n options: {\n implementation: require.resolve('postcss'),\n postcssOptions: {\n plugins: [\n [\n require.resolve('@tailwindcss/postcss'),\n { optimize: context.isProduction },\n ],\n ],\n },\n },\n },\n ],\n },\n ],\n },\n\n devServer: {\n ...(publicUrl.hostname ? { host: publicUrl.hostname } : {}),\n ...(publicUrl.port ? { port: publicUrl.port } : {}),\n historyApiFallback: true,\n hot: 'only',\n headers: {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n },\n },\n\n experiments: { css: true },\n\n plugins: [\n new rspack.EnvironmentPlugin({\n ...options.envVariables,\n PUBLIC_URL: publicUrl.toString(),\n }),\n new rspack.HtmlRspackPlugin({\n template: path.resolve(context.cwd, options.htmlTemplateFile),\n minify: context.isProduction,\n }),\n context.isServeMode && new ReactRefreshRspackPlugin({ forceEnable: true }),\n ],\n };\n};\n","import path from 'node:path';\n\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { ReactPresetOptions } from './react-preset';\nimport { getReactPresetDefaultOptions } from './react-preset';\n\nexport type FivemUiPresetOptions = ReactPresetOptions & {\n readonly resourceName: string;\n};\n\nexport const getFivemUiPresetDefaultOptions: GetPresetDefaultOptions<FivemUiPresetOptions> = (\n options,\n context,\n) => {\n const resourceName = options.resourceName ?? path.basename(context.cwd);\n const reactPresetOptions = getReactPresetDefaultOptions(options, context);\n return {\n ...reactPresetOptions,\n resourceName,\n publicUrl:\n options.publicUrl\n ?? (context.isServeMode ? 'http://localhost:8080/' : (\n `https://cfx-nui-${resourceName}/${reactPresetOptions.outDir}/`\n )),\n };\n};\n\nexport const fivemUiPreset: Preset<FivemUiPresetOptions> = (_options, context) => ({\n name: 'fivem-ui-preset',\n\n ...(context.isProduction ? { devtool: false } : {}),\n\n output: { filename: '[name].js' },\n\n devServer: {\n allowedHosts: 'all',\n devMiddleware: {\n writeToDisk: true,\n },\n },\n});\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nexport function findFirstExistingFile(files: string[], cwd: string): string | null {\n for (const file of files) if (fs.existsSync(path.resolve(cwd, file))) return file;\n return null;\n}\n","import type { RspackOptions } from '@rspack/core';\nimport { mergeWithRules } from 'webpack-merge';\n\nexport const mergeConfig = mergeWithRules({\n entry: 'replace',\n externals: 'replace',\n module: {\n rules: {\n test: 'match',\n options: 'merge',\n },\n },\n plugins: 'replace',\n}) as (...configs: RspackOptions[]) => RspackOptions;\n","import type { RspackOptions } from '@rspack/core';\n\nimport type {\n FivemScriptPresetOptions,\n FivemUiPresetOptions,\n NodePresetOptions,\n ReactPresetOptions,\n} from './presets';\nimport {\n basePreset,\n fivemScriptPreset,\n fivemUiPreset,\n getFivemScriptPresetDefaultOptions,\n getFivemUiPresetDefaultOptions,\n getNodePresetDefaultOptions,\n getReactPresetDefaultOptions,\n nodePreset,\n reactPreset,\n} from './presets';\nimport type { RspackEnv, RunContext } from './types';\nimport { findFirstExistingFile } from './utils/find-first-existing-file';\nimport { mergeConfig } from './utils/merge-config';\n\nfunction createConfigBuilder<TOptions, TReturn extends RspackOptions | RspackOptions[]>(\n func: (options: Partial<TOptions>, context: RunContext) => TReturn,\n) {\n return function (options: Partial<TOptions> = {}, context: Partial<RunContext> = {}) {\n return function (env: RspackEnv): TReturn {\n return func(options, {\n cwd: process.cwd(),\n isProduction: process.env.NODE_ENV === 'production',\n isBuildMode: Boolean(env.RSPACK_BUILD),\n isBundleMode: Boolean(env.RSPACK_BUNDLE),\n isWatchMode: Boolean(env.RSPACK_WATCH),\n isServeMode: Boolean(env.RSPACK_SERVE),\n ...context,\n });\n };\n };\n}\n\nexport const createNodeRspackConfig = createConfigBuilder<NodePresetOptions, RspackOptions>(\n (options, context) => {\n const presetOptions = getNodePresetDefaultOptions(options, context);\n\n return mergeConfig(basePreset(presetOptions, context), nodePreset(presetOptions, context), {\n name: 'node',\n });\n },\n);\n\nexport const createReactRspackConfig = createConfigBuilder<ReactPresetOptions, RspackOptions>(\n (options, context) => {\n const presetOptions = getReactPresetDefaultOptions(options, context);\n\n return mergeConfig(\n basePreset(presetOptions, context),\n reactPreset(presetOptions, context),\n {\n name: 'react',\n },\n );\n },\n);\n\nexport const createFivemScriptRspackConfig = createConfigBuilder<\n Omit<FivemScriptPresetOptions, 'entryFile' | 'outDir'>,\n RspackOptions[]\n>((options, context) => {\n const createBuildPreset = (type: 'client' | 'server' | 'shared') => {\n const entryFile = findFirstExistingFile(\n [`src/${type}/index.ts`, `src/${type}.ts`, `src/${type}/index.js`, `src/${type}.js`],\n context.cwd,\n );\n if (!entryFile) return null;\n\n const presetOptions = getFivemScriptPresetDefaultOptions(\n {\n ...options,\n entryFile,\n outDir: `dist/${type}`,\n },\n context,\n );\n\n return mergeConfig(\n basePreset(presetOptions, context),\n nodePreset(presetOptions, context),\n fivemScriptPreset(presetOptions, context),\n { name: `fivem-${type}` },\n );\n };\n\n const configs: (RspackOptions | null)[] = [];\n\n configs.push(createBuildPreset('client'));\n configs.push(createBuildPreset('server'));\n configs.push(createBuildPreset('shared'));\n\n return configs.filter(Boolean) as RspackOptions[];\n});\n\nexport const createFivemUiRspackConfig = createConfigBuilder<\n Omit<FivemUiPresetOptions, 'entryFile' | 'outDir' | 'htmlTemplateFile'>,\n RspackOptions\n>((options, context) => {\n const entryFile = findFirstExistingFile(\n [\n 'src/ui/index.tsx',\n 'src/ui.tsx',\n 'src/ui/index.ts',\n 'src/ui.ts',\n 'src/ui/index.jsx',\n 'src/ui.jsx',\n 'src/ui/index.js',\n 'src/ui.js',\n ],\n context.cwd,\n );\n\n const htmlTemplateFile = findFirstExistingFile(\n ['src/ui/index.html', 'src/ui.html', 'src/index.html'],\n context.cwd,\n );\n\n if (!entryFile || !htmlTemplateFile) return {};\n\n const presetOptions = getFivemUiPresetDefaultOptions(\n {\n ...options,\n entryFile,\n htmlTemplateFile,\n outDir: 'dist/ui',\n },\n context,\n );\n\n return mergeConfig(\n basePreset(presetOptions, context),\n reactPreset(presetOptions, context),\n fivemUiPreset(presetOptions, context),\n { name: 'fivem-ui' },\n );\n});\n"],"mappings":";;;;;;;;;AAAA,MAAa,eAAe;AAC5B,MAAa,kBAAkB;AAC/B,MAAa,gBAAgB;AAC7B,MAAa,6BAA6B;;;ACc1C,MAAa,+BACT,aACE;CACF,WAAW,QAAQ,aAAa;CAChC,cAAc,QAAQ,gBAAgB;CACtC,QAAQ,QAAQ,UAAU;CAC1B,cAAc,QAAQ,gBAAgB,CAAC;CACvC,eAAe,QAAQ,iBAAiB;CACxC,cAAc,QAAQ,gBAAgB;EAClC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ;AAEA,MAAa,cAAyC,SAAS,aAAa;CACxE,MAAM;CAEN,SAAS,QAAQ;CACjB,MAAM,QAAQ,eAAe,eAAe;CAE5C,OAAO,EAAE,MAAM,QAAQ,UAAU;CAEjC,QAAQ;EACJ,OAAO;EACP,MAAM,KAAK,QAAQ,QAAQ,KAAK,QAAQ,MAAM;CAClD;CAEA,SAAS;EACL,UAAU,KAAK,QAAQ,QAAQ,KAAK,QAAQ,YAAY;EACxD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O,GACpC,EAAE,MAAM,WAAW,CACvB;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["rspack","rspack","rspack"],"sources":["../src/constants.ts","../src/presets/base-preset.ts","../src/presets/node-preset.ts","../src/presets/fivem-script-preset.ts","../src/presets/react-preset.ts","../src/presets/fivem-ui-preset.ts","../src/utils/find-first-existing-file.ts","../src/utils/merge-config.ts","../src/create-rspack-config.ts"],"sourcesContent":["export const TS_RULE_TEST = /\\.(?:ts|tsx|cts|mts)$/iu;\nexport const ASSET_RULE_TEST = /\\.(?:jpe?g|png|gif|svg|webp|avif|ico|bmp|tiff?|eot|ttf|woff2?)$/iu;\nexport const CSS_RULE_TEST = /\\.css$/iu;\nexport const HASHED_JS_FILENAME_PATTERN = '[name].[contenthash:8].js';\n","import path from 'node:path';\n\nimport type { SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\n\nimport { TS_RULE_TEST } from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nexport type BasePresetOptions = {\n readonly entryFile: string;\n readonly tsconfigFile: string;\n readonly outDir: string;\n readonly envVariables: Record<string, string | undefined>;\n readonly useDecorators: boolean;\n readonly watchIgnored: string[];\n};\n\nexport const getBasePresetDefaultOptions: GetPresetDefaultOptions<BasePresetOptions> = (\n options,\n) => ({\n entryFile: options.entryFile ?? './src/index.js',\n tsconfigFile: options.tsconfigFile ?? 'tsconfig.json',\n outDir: options.outDir ?? 'dist',\n envVariables: options.envVariables ?? {},\n useDecorators: options.useDecorators ?? false,\n watchIgnored: options.watchIgnored ?? [\n '**/.git',\n '**/.turbo',\n '**/coverage',\n '**/dist',\n '**/target',\n '**/generated',\n '**/old',\n '**/tmp',\n ],\n});\n\nexport const basePreset: Preset<BasePresetOptions> = (options, context) => ({\n name: 'base-preset',\n\n context: context.cwd,\n mode: context.isProduction ? 'production' : 'development',\n\n entry: { main: options.entryFile },\n\n output: {\n clean: true,\n path: path.resolve(context.cwd, options.outDir),\n },\n\n resolve: {\n tsConfig: path.resolve(context.cwd, options.tsconfigFile),\n extensions: ['.ts', '...'],\n extensionAlias: {\n '.js': ['.ts', '.js'],\n '.cts': ['.cts', '.js'],\n '.mjs': ['.mts', '.mjs'],\n },\n },\n\n optimization: { minimize: context.isProduction },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n type: 'javascript/auto',\n loader: 'builtin:swc-loader',\n exclude: [/dist\\//u, /node_modules\\//u],\n options: {\n jsc: {\n externalHelpers: false,\n keepClassNames: true,\n parser: {\n syntax: 'typescript',\n decorators: options.useDecorators,\n },\n transform: {\n useDefineForClassFields: true,\n legacyDecorator: options.useDecorators,\n decoratorMetadata: options.useDecorators,\n },\n experimental: {\n cacheRoot: path.resolve(context.cwd, 'node_modules/.cache/swc'),\n },\n },\n } satisfies SwcLoaderOptions,\n },\n ],\n },\n\n cache:\n !context.isProduction ?\n {\n type: 'persistent',\n storage: {\n type: 'filesystem',\n directory: path.resolve(context.cwd, 'node_modules/.cache/rspack'),\n },\n }\n : false,\n\n stats: {\n preset: 'normal',\n errorDetails: true,\n colors: true,\n },\n\n watchOptions: {\n aggregateTimeout: 200,\n ignored: options.watchIgnored,\n },\n\n plugins: [new rspack.EnvironmentPlugin(options.envVariables)],\n});\n","import type { ExternalItem, SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';\nimport nodeExternals from 'webpack-node-externals';\n\nimport { TS_RULE_TEST } from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { BasePresetOptions } from './base-preset';\nimport { getBasePresetDefaultOptions } from './base-preset';\n\nexport type NodePresetOptions = BasePresetOptions & {\n readonly nodeVersion: number;\n};\n\nexport const getNodePresetDefaultOptions: GetPresetDefaultOptions<NodePresetOptions> = (\n options,\n context,\n) => ({\n ...getBasePresetDefaultOptions(options, context),\n nodeVersion: options.nodeVersion ?? 24,\n});\n\nexport const nodePreset: Preset<NodePresetOptions> = (options, context) => ({\n name: 'node-preset',\n\n target: `node${options.nodeVersion}`,\n\n entry: {\n main: [...(context.isServeMode ? ['@rspack/core/hot/poll?100'] : []), options.entryFile],\n },\n\n externalsPresets: { node: true },\n externalsType: 'commonjs',\n externals: [\n nodeExternals(\n context.isServeMode ? { allowlist: ['@rspack/core/hot/poll?100'] } : undefined,\n ) as ExternalItem,\n ],\n\n optimization: { minimize: false },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n loader: 'builtin:swc-loader',\n options: {\n env: { targets: `node ${options.nodeVersion}` },\n } satisfies SwcLoaderOptions,\n },\n ],\n },\n\n devServer: {\n devMiddleware: {\n writeToDisk: true,\n },\n },\n\n plugins: [\n new rspack.EnvironmentPlugin(options.envVariables),\n context.isServeMode && new RunScriptWebpackPlugin({ name: 'main.js', autoRestart: false }),\n ],\n});\n","import rspack from '@rspack/core';\n\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { NodePresetOptions } from './node-preset';\nimport { getNodePresetDefaultOptions } from './node-preset';\n\nexport type FivemScriptPresetOptions = NodePresetOptions;\n\nexport const getFivemScriptPresetDefaultOptions: GetPresetDefaultOptions<\n FivemScriptPresetOptions\n> = (options, context) => ({\n ...getNodePresetDefaultOptions(options, context),\n nodeVersion: options.nodeVersion ?? 16,\n});\n\nexport const fivemScriptPreset: Preset<FivemScriptPresetOptions> = (options, context) => ({\n name: 'fivem-script-preset',\n\n devtool: false,\n\n externals: [],\n\n optimization: { minimize: context.isProduction },\n\n plugins: [new rspack.EnvironmentPlugin(options.envVariables)],\n});\n","import { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { SwcLoaderOptions } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';\n\nimport {\n ASSET_RULE_TEST,\n CSS_RULE_TEST,\n HASHED_JS_FILENAME_PATTERN,\n TS_RULE_TEST,\n} from '~/constants';\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { BasePresetOptions } from './base-preset';\nimport { getBasePresetDefaultOptions } from './base-preset';\n\nconst require = createRequire(import.meta.url);\n\nexport type ReactPresetOptions = BasePresetOptions & {\n readonly htmlTemplateFile: string;\n readonly browserlist: string;\n readonly publicUrl: string;\n};\n\nexport const getReactPresetDefaultOptions: GetPresetDefaultOptions<ReactPresetOptions> = (\n options,\n context,\n) => ({\n ...getBasePresetDefaultOptions(options, context),\n htmlTemplateFile: options.htmlTemplateFile ?? 'src/index.html',\n browserlist: options.browserlist ?? 'defaults',\n publicUrl: options.publicUrl ?? 'http://localhost:8080/',\n});\n\nexport const reactPreset: Preset<ReactPresetOptions> = (options, context) => {\n const publicUrl = new URL(options.publicUrl);\n if (!publicUrl.pathname.endsWith('/')) publicUrl.pathname += '/';\n\n return {\n name: 'react-preset',\n\n target: `browserslist:${options.browserlist}`,\n\n output: {\n filename: context.isProduction ? HASHED_JS_FILENAME_PATTERN : '[name].js',\n publicPath: publicUrl.toString(),\n },\n\n resolve: {\n extensions: ['.tsx', '.ts', '.jsx', '...'],\n extensionAlias: {\n '.js': ['.tsx', '.ts', '.jsx', '.js'],\n '.cts': ['.ctsx', '.cts', '.cjsx', '.js'],\n '.mjs': ['.mtsx', '.mts', '.mjsx', '.mjs'],\n },\n },\n\n externalsPresets: { web: true },\n\n module: {\n rules: [\n {\n test: TS_RULE_TEST,\n loader: 'builtin:swc-loader',\n options: {\n env: { targets: options.browserlist },\n jsc: {\n parser: {\n syntax: 'typescript',\n tsx: true,\n },\n transform: {\n react: {\n runtime: 'automatic',\n throwIfNamespace: true,\n useBuiltins: false,\n development: !context.isProduction,\n refresh: context.isServeMode,\n },\n },\n },\n } satisfies SwcLoaderOptions,\n },\n {\n test: ASSET_RULE_TEST,\n type: 'asset/resource',\n },\n {\n test: CSS_RULE_TEST,\n type: 'css',\n use: [\n {\n loader: require.resolve('postcss-loader'),\n options: {\n implementation: require.resolve('postcss'),\n postcssOptions: {\n plugins: [\n [\n require.resolve('@tailwindcss/postcss'),\n { optimize: context.isProduction },\n ],\n ],\n },\n },\n },\n ],\n },\n ],\n },\n\n devServer: {\n ...(publicUrl.hostname ? { host: publicUrl.hostname } : {}),\n ...(publicUrl.port ? { port: publicUrl.port } : {}),\n historyApiFallback: true,\n hot: 'only',\n headers: {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n },\n },\n\n experiments: { css: true },\n\n plugins: [\n new rspack.EnvironmentPlugin({\n ...options.envVariables,\n PUBLIC_URL: publicUrl.toString(),\n }),\n new rspack.HtmlRspackPlugin({\n template: path.resolve(context.cwd, options.htmlTemplateFile),\n minify: context.isProduction,\n }),\n context.isServeMode && new ReactRefreshRspackPlugin({ forceEnable: true }),\n ],\n };\n};\n","import path from 'node:path';\n\nimport type { GetPresetDefaultOptions, Preset } from '~/types';\n\nimport type { ReactPresetOptions } from './react-preset';\nimport { getReactPresetDefaultOptions } from './react-preset';\n\nexport type FivemUiPresetOptions = ReactPresetOptions & {\n readonly resourceName: string;\n};\n\nexport const getFivemUiPresetDefaultOptions: GetPresetDefaultOptions<FivemUiPresetOptions> = (\n options,\n context,\n) => {\n const resourceName = options.resourceName ?? path.basename(context.cwd);\n const reactPresetOptions = getReactPresetDefaultOptions(options, context);\n return {\n ...reactPresetOptions,\n resourceName,\n publicUrl:\n options.publicUrl\n ?? (context.isServeMode ? 'http://localhost:8080/' : (\n `https://cfx-nui-${resourceName}/${reactPresetOptions.outDir}/`\n )),\n };\n};\n\nexport const fivemUiPreset: Preset<FivemUiPresetOptions> = (_options, context) => ({\n name: 'fivem-ui-preset',\n\n ...(context.isProduction ? { devtool: false } : {}),\n\n output: { filename: '[name].js' },\n\n devServer: {\n allowedHosts: 'all',\n devMiddleware: {\n writeToDisk: true,\n },\n },\n});\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nexport function findFirstExistingFile(files: string[], cwd: string): string | null {\n for (const file of files) if (fs.existsSync(path.resolve(cwd, file))) return file;\n return null;\n}\n","import type { RspackOptions } from '@rspack/core';\nimport { mergeWithRules } from 'webpack-merge';\n\nexport const mergeConfig = mergeWithRules({\n entry: 'replace',\n externals: 'replace',\n module: {\n rules: {\n test: 'match',\n options: 'merge',\n },\n },\n plugins: 'replace',\n}) as (...configs: RspackOptions[]) => RspackOptions;\n","import type { RspackOptions } from '@rspack/core';\n\nimport type {\n FivemScriptPresetOptions,\n FivemUiPresetOptions,\n NodePresetOptions,\n ReactPresetOptions,\n} from './presets';\nimport {\n basePreset,\n fivemScriptPreset,\n fivemUiPreset,\n getFivemScriptPresetDefaultOptions,\n getFivemUiPresetDefaultOptions,\n getNodePresetDefaultOptions,\n getReactPresetDefaultOptions,\n nodePreset,\n reactPreset,\n} from './presets';\nimport type { RspackEnv, RunContext } from './types';\nimport { findFirstExistingFile } from './utils/find-first-existing-file';\nimport { mergeConfig } from './utils/merge-config';\n\nfunction createConfigBuilder<TOptions, TReturn extends RspackOptions | RspackOptions[]>(\n func: (options: Partial<TOptions>, context: RunContext) => TReturn,\n) {\n return function (options: Partial<TOptions> = {}, context: Partial<RunContext> = {}) {\n return function (env: RspackEnv): TReturn {\n return func(options, {\n cwd: process.cwd(),\n isProduction: process.env.NODE_ENV === 'production',\n isBuildMode: Boolean(env.RSPACK_BUILD),\n isBundleMode: Boolean(env.RSPACK_BUNDLE),\n isWatchMode: Boolean(env.RSPACK_WATCH),\n isServeMode: Boolean(env.RSPACK_SERVE),\n ...context,\n });\n };\n };\n}\n\nexport const createNodeRspackConfig = createConfigBuilder<NodePresetOptions, RspackOptions>(\n (options, context) => {\n const presetOptions = getNodePresetDefaultOptions(options, context);\n\n return mergeConfig(basePreset(presetOptions, context), nodePreset(presetOptions, context), {\n name: 'node',\n });\n },\n);\n\nexport const createReactRspackConfig = createConfigBuilder<ReactPresetOptions, RspackOptions>(\n (options, context) => {\n const presetOptions = getReactPresetDefaultOptions(options, context);\n\n return mergeConfig(\n basePreset(presetOptions, context),\n reactPreset(presetOptions, context),\n {\n name: 'react',\n },\n );\n },\n);\n\nexport const createFivemScriptRspackConfig = createConfigBuilder<\n Omit<FivemScriptPresetOptions, 'entryFile' | 'outDir'>,\n RspackOptions[]\n>((options, context) => {\n const createBuildPreset = (type: 'client' | 'server' | 'shared') => {\n const entryFile = findFirstExistingFile(\n [`src/${type}/index.ts`, `src/${type}.ts`, `src/${type}/index.js`, `src/${type}.js`],\n context.cwd,\n );\n if (!entryFile) return null;\n\n const presetOptions = getFivemScriptPresetDefaultOptions(\n {\n ...options,\n entryFile,\n outDir: `dist/${type}`,\n },\n context,\n );\n\n return mergeConfig(\n basePreset(presetOptions, context),\n nodePreset(presetOptions, context),\n fivemScriptPreset(presetOptions, context),\n { name: `fivem-${type}` },\n );\n };\n\n const configs: (RspackOptions | null)[] = [];\n\n configs.push(createBuildPreset('client'));\n configs.push(createBuildPreset('server'));\n configs.push(createBuildPreset('shared'));\n\n return configs.filter(Boolean) as RspackOptions[];\n});\n\nexport const createFivemUiRspackConfig = createConfigBuilder<\n Omit<FivemUiPresetOptions, 'entryFile' | 'outDir' | 'htmlTemplateFile'>,\n RspackOptions\n>((options, context) => {\n const entryFile = findFirstExistingFile(\n [\n 'src/ui/index.tsx',\n 'src/ui.tsx',\n 'src/ui/index.ts',\n 'src/ui.ts',\n 'src/ui/index.jsx',\n 'src/ui.jsx',\n 'src/ui/index.js',\n 'src/ui.js',\n ],\n context.cwd,\n );\n\n const htmlTemplateFile = findFirstExistingFile(\n ['src/ui/index.html', 'src/ui.html', 'src/index.html'],\n context.cwd,\n );\n\n if (!entryFile || !htmlTemplateFile) return {};\n\n const presetOptions = getFivemUiPresetDefaultOptions(\n {\n ...options,\n entryFile,\n htmlTemplateFile,\n outDir: 'dist/ui',\n },\n context,\n );\n\n return mergeConfig(\n basePreset(presetOptions, context),\n reactPreset(presetOptions, context),\n fivemUiPreset(presetO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jC,kBAAkB,eAAe,OAAO,GACxC,EAAE,MAAM,SAAS,OAAO,CAC5B;CACJ;CAEA,MAAM,UAAoC,CAAC;CAE3C,QAAQ,KAAK,kBAAkB,QAAQ,CAAC;CACxC,QAAQ,KAAK,kBAAkB,QAAQ,CAAC;CACxC,QAAQ,KAAK,kBAAkB,QAAQ,CAAC;CAExC,OAAO,QAAQ,OAAO,OAAO;AACjC,CAAC;AAED,MAAa,4BAA4B,qBAGtC,SAAS,YAAY;CACpB,MAAM,YAAY,sBACd;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,GACA,QAAQ,GACZ;CAEA,MAAM,mBAAmB,sBACrB;EAAC;EAAqB;EAAe;CAAgB,GACrD,QAAQ,GACZ;CAEA,IAAI,CAAC,aAAa,CAAC,kBAAkB,OAAO,CAAC;CAE7C,MAAM,gBAAgB,+BAClB;EACI,GAAG;EACH;EACA;EACA,QAAQ;CACZ,GACA,OACJ;CAEA,OAAO,YACH,WAAW,eAAe,OAAO,GACjC,YAAY,eAAe,OAAO,GAClC,cAAc,eAAe,OAAO,GACpC,EAAE,MAAM,WAAW,CACvB;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpp-toolkit/rspack-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.79",
|
|
4
4
|
"description": "Rspack configurations for JS/TS projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jpp",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@rspack/core": "2.1.3",
|
|
35
35
|
"@rspack/plugin-react-refresh": "2.0.2",
|
|
36
36
|
"@tailwindcss/postcss": "4.3.2",
|
|
37
|
-
"postcss": "8.5.
|
|
37
|
+
"postcss": "8.5.18",
|
|
38
38
|
"postcss-loader": "8.2.1",
|
|
39
39
|
"react-refresh": "0.18.0",
|
|
40
40
|
"run-script-webpack-plugin": "0.2.3",
|