@lynx-js/rspeedy 0.8.2
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/CHANGELOG.md +208 -0
- package/LICENSE +202 -0
- package/README.md +32 -0
- package/bin/rspeedy.js +33 -0
- package/client/hmr/WebSocketClient.js +65 -0
- package/client.d.ts +5 -0
- package/lib/api.d.ts +46 -0
- package/lib/api.js +2 -0
- package/lib/cli/build.d.ts +4 -0
- package/lib/cli/build.js +32 -0
- package/lib/cli/commands.d.ts +5 -0
- package/lib/cli/commands.js +45 -0
- package/lib/cli/dev.d.ts +4 -0
- package/lib/cli/dev.js +75 -0
- package/lib/cli/exit.d.ts +1 -0
- package/lib/cli/exit.js +51 -0
- package/lib/cli/inspect.d.ts +8 -0
- package/lib/cli/inspect.js +30 -0
- package/lib/cli/main.d.ts +1 -0
- package/lib/cli/main.js +39 -0
- package/lib/cli/preview.d.ts +4 -0
- package/lib/cli/preview.js +31 -0
- package/lib/cli/start.d.ts +6 -0
- package/lib/cli/start.js +88 -0
- package/lib/config/defaults.d.ts +2 -0
- package/lib/config/defaults.js +32 -0
- package/lib/config/defineConfig.d.ts +22 -0
- package/lib/config/defineConfig.js +24 -0
- package/lib/config/dev/client.d.ts +15 -0
- package/lib/config/dev/client.js +2 -0
- package/lib/config/dev/index.d.ts +133 -0
- package/lib/config/dev/index.js +2 -0
- package/lib/config/index.d.ts +172 -0
- package/lib/config/index.js +2 -0
- package/lib/config/loadConfig.d.ts +50 -0
- package/lib/config/loadConfig.js +98 -0
- package/lib/config/output/css-modules.d.ts +84 -0
- package/lib/config/output/css-modules.js +2 -0
- package/lib/config/output/dist-path.d.ts +68 -0
- package/lib/config/output/dist-path.js +2 -0
- package/lib/config/output/filename.d.ts +167 -0
- package/lib/config/output/filename.js +2 -0
- package/lib/config/output/index.d.ts +320 -0
- package/lib/config/output/index.js +2 -0
- package/lib/config/output/minify.d.ts +80 -0
- package/lib/config/output/minify.js +2 -0
- package/lib/config/output/source-map.d.ts +68 -0
- package/lib/config/output/source-map.js +2 -0
- package/lib/config/performance/chunk-split.d.ts +192 -0
- package/lib/config/performance/chunk-split.js +2 -0
- package/lib/config/performance/index.d.ts +50 -0
- package/lib/config/performance/index.js +2 -0
- package/lib/config/rsbuild/entry.d.ts +3 -0
- package/lib/config/rsbuild/entry.js +31 -0
- package/lib/config/rsbuild/index.d.ts +4 -0
- package/lib/config/rsbuild/index.js +70 -0
- package/lib/config/server/index.d.ts +47 -0
- package/lib/config/server/index.js +2 -0
- package/lib/config/source/decorators.d.ts +43 -0
- package/lib/config/source/decorators.js +2 -0
- package/lib/config/source/entry.d.ts +84 -0
- package/lib/config/source/entry.js +2 -0
- package/lib/config/source/index.d.ts +474 -0
- package/lib/config/source/index.js +2 -0
- package/lib/config/source/transformImport.d.ts +106 -0
- package/lib/config/source/transformImport.js +2 -0
- package/lib/config/tools/css-extract.d.ts +72 -0
- package/lib/config/tools/css-extract.js +2 -0
- package/lib/config/tools/css-loader.d.ts +130 -0
- package/lib/config/tools/css-loader.js +2 -0
- package/lib/config/tools/index.d.ts +170 -0
- package/lib/config/tools/index.js +2 -0
- package/lib/config/validate.d.ts +4 -0
- package/lib/config/validate.js +28962 -0
- package/lib/create-rspeedy.d.ts +45 -0
- package/lib/create-rspeedy.js +48 -0
- package/lib/debug.d.ts +3 -0
- package/lib/debug.js +25 -0
- package/lib/index.d.ts +45 -0
- package/lib/index.js +10 -0
- package/lib/plugins/api.plugin.d.ts +3 -0
- package/lib/plugins/api.plugin.js +25 -0
- package/lib/plugins/chunkLoading.plugin.d.ts +2 -0
- package/lib/plugins/chunkLoading.plugin.js +30 -0
- package/lib/plugins/dev.plugin.d.ts +5 -0
- package/lib/plugins/dev.plugin.js +130 -0
- package/lib/plugins/index.d.ts +3 -0
- package/lib/plugins/index.js +49 -0
- package/lib/plugins/inspect.plugin.d.ts +4 -0
- package/lib/plugins/inspect.plugin.js +39 -0
- package/lib/plugins/minify.plugin.d.ts +3 -0
- package/lib/plugins/minify.plugin.js +89 -0
- package/lib/plugins/optimization.plugin.d.ts +2 -0
- package/lib/plugins/optimization.plugin.js +31 -0
- package/lib/plugins/output.plugin.d.ts +3 -0
- package/lib/plugins/output.plugin.js +34 -0
- package/lib/plugins/resolve.plugin.d.ts +2 -0
- package/lib/plugins/resolve.plugin.js +38 -0
- package/lib/plugins/rsdoctor.plugin.d.ts +3 -0
- package/lib/plugins/rsdoctor.plugin.js +41 -0
- package/lib/plugins/sourcemap.plugin.d.ts +2 -0
- package/lib/plugins/sourcemap.plugin.js +84 -0
- package/lib/plugins/stats.plugin.d.ts +2 -0
- package/lib/plugins/stats.plugin.js +20 -0
- package/lib/plugins/swc.plugin.d.ts +2 -0
- package/lib/plugins/swc.plugin.js +21 -0
- package/lib/plugins/target.plugin.d.ts +2 -0
- package/lib/plugins/target.plugin.js +12 -0
- package/lib/utils/getESVersionTarget.d.ts +1 -0
- package/lib/utils/getESVersionTarget.js +7 -0
- package/lib/utils/is-ci.d.ts +1 -0
- package/lib/utils/is-ci.js +7 -0
- package/lib/version.d.ts +4 -0
- package/lib/version.js +15 -0
- package/lib/webpack/CompilationIdPlugin.d.ts +4 -0
- package/lib/webpack/CompilationIdPlugin.js +20 -0
- package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +9 -0
- package/lib/webpack/EvalSourceMapDevToolPlugin.js +15 -0
- package/lib/webpack/ProvidePlugin.d.ts +9 -0
- package/lib/webpack/ProvidePlugin.js +15 -0
- package/lib/webpack/SourceMapDevToolPlugin.d.ts +9 -0
- package/lib/webpack/SourceMapDevToolPlugin.js +15 -0
- package/package.json +83 -0
- package/register/data.d.ts +9 -0
- package/register/hooks.js +146 -0
- package/register/index.d.ts +4 -0
- package/register/index.js +47 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { RsbuildConfig, RsbuildPlugins } from '@rsbuild/core';
|
|
2
|
+
import type { Dev } from './dev/index.js';
|
|
3
|
+
import type { Output } from './output/index.js';
|
|
4
|
+
import type { Performance } from './performance/index.js';
|
|
5
|
+
import type { Server } from './server/index.js';
|
|
6
|
+
import type { Source } from './source/index.js';
|
|
7
|
+
import type { Tools } from './tools/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* The `Config` is the configuration that `rspeedy` uses.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface Config {
|
|
14
|
+
/**
|
|
15
|
+
* The Rsbuild provider.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* You can switch from Rspack to Webpack by:
|
|
19
|
+
*
|
|
20
|
+
* - Use `webpackProvider` from `@rsbuild/webpack`
|
|
21
|
+
* - Add `pluginSwc` from `@rsbuild/plugin-webpack-swc` for TypeScript transpilation
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
25
|
+
* import { webpackProvider } from '@rsbuild/webpack'
|
|
26
|
+
* import { pluginSwc } from '@rsbuild/plugin-webpack-swc'
|
|
27
|
+
*
|
|
28
|
+
* export default defineConfig({
|
|
29
|
+
* provider: webpackProvider,
|
|
30
|
+
* plugins: [
|
|
31
|
+
* pluginSwc(),
|
|
32
|
+
* ],
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
provider?: RsbuildConfig['provider'];
|
|
39
|
+
/**
|
|
40
|
+
* The {@link Dev} option is used to control the behavior related with development. Including: HMR, DevServer, etc.
|
|
41
|
+
*/
|
|
42
|
+
dev?: Dev | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The {@link Config.environments} option is used to set the output environment.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
*
|
|
48
|
+
* Normally you don't need this if you are not using Lynx for Web.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
*
|
|
52
|
+
* - Using different entries for Lynx and Web.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
56
|
+
*
|
|
57
|
+
* export default defineConfig({
|
|
58
|
+
* environments: {
|
|
59
|
+
* lynx: {},
|
|
60
|
+
* web: {
|
|
61
|
+
* source: { entry: { web: './src/index.web.jsx' } },
|
|
62
|
+
* },
|
|
63
|
+
* },
|
|
64
|
+
* source: {
|
|
65
|
+
* entry: './src/index.jsx',
|
|
66
|
+
* },
|
|
67
|
+
* })
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
*
|
|
72
|
+
* - Building Web-only outputs.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
76
|
+
*
|
|
77
|
+
* export default defineConfig({
|
|
78
|
+
* environments: {
|
|
79
|
+
* web: {
|
|
80
|
+
* source: { entry: { web: './src/index.web.jsx' } },
|
|
81
|
+
* },
|
|
82
|
+
* },
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
environments?: RsbuildConfig['environments'] | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Specify the build mode for Rsbuild and Rspack, as each mode has different default behavior and optimizations.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
*
|
|
92
|
+
* The default value of mode depends on the `process.env.NODE_ENV` environment variable:
|
|
93
|
+
*
|
|
94
|
+
* - If `NODE_ENV` is production, the default value is production.
|
|
95
|
+
*
|
|
96
|
+
* - If `NODE_ENV` is development, the default value is development.
|
|
97
|
+
*
|
|
98
|
+
* - If `NODE_ENV` has any other value, the default value is none.
|
|
99
|
+
*
|
|
100
|
+
* - If you set the value of mode, the value of `NODE_ENV` will be ignored.
|
|
101
|
+
*
|
|
102
|
+
* When using Rspeedy's CLI:
|
|
103
|
+
*
|
|
104
|
+
* - `rspeedy dev` and `rspeedy preview` will set the default values of `NODE_ENV` and `mode` to `'development'`.
|
|
105
|
+
*
|
|
106
|
+
* - `rspeedy build` will set the default values of `NODE_ENV` and `mode` to `'production'`.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
*
|
|
110
|
+
* If the value of `mode` is `'development'`:
|
|
111
|
+
*
|
|
112
|
+
* - Enable HMR and register the {@link https://rspack.dev/plugins/webpack/hot-module-replacement-plugin | HotModuleReplacementPlugin}.
|
|
113
|
+
*
|
|
114
|
+
* - Generate JavaScript source maps, but do not generate CSS source maps. See {@link Output.sourceMap} for details.
|
|
115
|
+
*
|
|
116
|
+
* - The `process.env.NODE_ENV` in the source code will be replaced with `'development'`.
|
|
117
|
+
*
|
|
118
|
+
* - The `import.meta.env.MODE` in the source code will be replaced with `'development'`.
|
|
119
|
+
*
|
|
120
|
+
* - The `import.meta.env.DEV` in the source code will be replaced with `true`.
|
|
121
|
+
*
|
|
122
|
+
* - The `import.meta.env.PROD` in the source code will be replaced with `false`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
*
|
|
126
|
+
* If the value of `mode` is `'production'`:
|
|
127
|
+
*
|
|
128
|
+
* - Enable JavaScript code minification and register the {@link https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
|
|
129
|
+
*
|
|
130
|
+
* - Generated JavaScript and CSS filenames will have hash suffixes, see {@link Output.filenameHash}.
|
|
131
|
+
*
|
|
132
|
+
* - Generated CSS Modules classnames will be shorter, see {@link CssModules.localIdentName}.
|
|
133
|
+
*
|
|
134
|
+
* - Do not generate JavaScript and CSS source maps, see {@link Output.sourceMap}.
|
|
135
|
+
*
|
|
136
|
+
* - The `process.env.NODE_ENV` in the source code will be replaced with `'production'`.
|
|
137
|
+
*
|
|
138
|
+
* - The `import.meta.env.MODE` in the source code will be replaced with `'production'`.
|
|
139
|
+
*
|
|
140
|
+
* - The `import.meta.env.DEV` in the source code will be replaced with `false`.
|
|
141
|
+
*
|
|
142
|
+
* - The `import.meta.env.PROD` in the source code will be replaced with `true`.
|
|
143
|
+
*/
|
|
144
|
+
mode?: 'development' | 'production' | 'none' | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* The {@link Output} option is used to set how and where should the bundles and assets output.
|
|
147
|
+
*/
|
|
148
|
+
output?: Output | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* The {@link Performance} option is used to
|
|
151
|
+
*/
|
|
152
|
+
performance?: Performance | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* The {@link Server} option changes the behavior of dev-server.
|
|
155
|
+
*/
|
|
156
|
+
server?: Server | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* The {@link Source} option changes the behavior of source files.
|
|
159
|
+
*/
|
|
160
|
+
source?: Source | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* The {@link Tools} options changes the behavior of various building tools.
|
|
163
|
+
*/
|
|
164
|
+
tools?: Tools | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* The `plugins` option is used to customize the build process in a variety of ways.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* Rspeedy use the plugin APIs from {@link https://rsbuild.dev/plugins/dev/index | Rsbuild}. See the corresponding document for developing a plugin.
|
|
170
|
+
*/
|
|
171
|
+
plugins?: RsbuildPlugins | undefined;
|
|
172
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Config } from './index.js';
|
|
2
|
+
export declare const resolveConfigPath: (root: string, customConfig?: string) => string;
|
|
3
|
+
/**
|
|
4
|
+
* The options of loadConfig.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface LoadConfigOptions {
|
|
9
|
+
configPath?: string | undefined;
|
|
10
|
+
cwd?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The result of {@link loadConfig}.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface LoadConfigResult {
|
|
18
|
+
/**
|
|
19
|
+
* The configuration object that exported from the configuration file.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
*
|
|
23
|
+
* The returned object has already been validated.
|
|
24
|
+
*/
|
|
25
|
+
content: Config;
|
|
26
|
+
/**
|
|
27
|
+
* The configuration path that has been loaded.
|
|
28
|
+
*/
|
|
29
|
+
configPath: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load the build config by the config path.
|
|
33
|
+
*
|
|
34
|
+
* @param loadConfigOptions - the options of `loadConfig` method.
|
|
35
|
+
* @returns Build config.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { loadConfig } from '@lynx-js/rspeedy'
|
|
41
|
+
*
|
|
42
|
+
* void async function () {
|
|
43
|
+
* const config = await loadConfig({ configPath: './lynx.config.js' })
|
|
44
|
+
* console.log(config);
|
|
45
|
+
* }()
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare function loadConfig(loadConfigOptions: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { extname, isAbsolute, join } from 'node:path';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
7
|
+
import color from 'picocolors';
|
|
8
|
+
import { validate } from './validate.js';
|
|
9
|
+
import { register } from '../../register/index.js';
|
|
10
|
+
import { debug } from '../debug.js';
|
|
11
|
+
export const resolveConfigPath = (root, customConfig) => {
|
|
12
|
+
if (customConfig) {
|
|
13
|
+
debug(`load custom config file ${customConfig} from ${root}`);
|
|
14
|
+
const customConfigPath = isAbsolute(customConfig)
|
|
15
|
+
? customConfig
|
|
16
|
+
: join(root, customConfig);
|
|
17
|
+
if (fs.existsSync(customConfigPath)) {
|
|
18
|
+
return customConfigPath;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`Cannot find config file: ${color.dim(customConfigPath)}`);
|
|
21
|
+
}
|
|
22
|
+
const CONFIG_FILES = [
|
|
23
|
+
'lynx.config.ts',
|
|
24
|
+
'lynx.config.js',
|
|
25
|
+
'lynx.config.mts',
|
|
26
|
+
'lynx.config.mjs',
|
|
27
|
+
];
|
|
28
|
+
for (const file of CONFIG_FILES) {
|
|
29
|
+
debug(`load default config file ${file} from ${root}`);
|
|
30
|
+
const configFile = join(root, file);
|
|
31
|
+
if (fs.existsSync(configFile)) {
|
|
32
|
+
debug(`default config ${configFile} found`);
|
|
33
|
+
return configFile;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw new Error([
|
|
37
|
+
`Cannot find the default config file: ${color.dim(join(root, CONFIG_FILES[0]))}.`,
|
|
38
|
+
`Use custom config with ${color.green('`--config <config>`')} options.`,
|
|
39
|
+
].join(' '));
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Load the build config by the config path.
|
|
43
|
+
*
|
|
44
|
+
* @param loadConfigOptions - the options of `loadConfig` method.
|
|
45
|
+
* @returns Build config.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { loadConfig } from '@lynx-js/rspeedy'
|
|
51
|
+
*
|
|
52
|
+
* void async function () {
|
|
53
|
+
* const config = await loadConfig({ configPath: './lynx.config.js' })
|
|
54
|
+
* console.log(config);
|
|
55
|
+
* }()
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export async function loadConfig(loadConfigOptions) {
|
|
61
|
+
let { configPath } = loadConfigOptions;
|
|
62
|
+
if (!configPath || !isAbsolute(configPath)) {
|
|
63
|
+
configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
64
|
+
}
|
|
65
|
+
// Note that we are using `pathToFileURL` since absolute paths must be valid file:// URLs on Windows.
|
|
66
|
+
const specifier = pathToFileURL(configPath).toString();
|
|
67
|
+
const unregister = shouldUseNativeImport(configPath)
|
|
68
|
+
? /** noop */ () => void 0
|
|
69
|
+
: register();
|
|
70
|
+
try {
|
|
71
|
+
const exports = await import(
|
|
72
|
+
/* webpackIgnore: true */ `${specifier}?t=${Date.now()}`);
|
|
73
|
+
const content = validate('default' in exports ? exports.default : exports, configPath);
|
|
74
|
+
return {
|
|
75
|
+
configPath,
|
|
76
|
+
content,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
unregister();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function shouldUseNativeImport(configPath) {
|
|
84
|
+
return isJavaScriptPath(configPath) || hasNativeTSSupport();
|
|
85
|
+
}
|
|
86
|
+
function hasNativeTSSupport() {
|
|
87
|
+
const { NODE_OPTIONS } = process.env;
|
|
88
|
+
if (!NODE_OPTIONS) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return NODE_OPTIONS.includes('--experimental-transform-types')
|
|
92
|
+
|| NODE_OPTIONS.includes('--experimental-strip-types');
|
|
93
|
+
}
|
|
94
|
+
function isJavaScriptPath(configPath) {
|
|
95
|
+
const ext = extname(configPath);
|
|
96
|
+
return ['.js', '.mjs', '.cjs'].includes(ext);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=loadConfig.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@inheritdoc Output.cssModules}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface CssModules {
|
|
7
|
+
/**
|
|
8
|
+
* The `auto` option allows CSS modules to be automatically enabled based on their filenames.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* Given the various `auto` values, the behavior is described as follows:
|
|
13
|
+
*
|
|
14
|
+
* - `true`: enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` RegExp.
|
|
15
|
+
*
|
|
16
|
+
* - `false`: disable CSS modules.
|
|
17
|
+
*
|
|
18
|
+
* - `RegExp`: enable CSS modules for all files matching the `auto.test(filename)` RegExp.
|
|
19
|
+
*
|
|
20
|
+
* - `function`: enable CSS modules based on the filter function.
|
|
21
|
+
*
|
|
22
|
+
* See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#auto | css-loader#auto} for details.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* Enable CSS module for `*.module.css` and `shared/*.css`:
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
30
|
+
* export default defineConfig({
|
|
31
|
+
* output: {
|
|
32
|
+
* cssModules: {
|
|
33
|
+
* auto: (filename) => {
|
|
34
|
+
* return filename.includes('.module.') || filename.includes('shared/')
|
|
35
|
+
* },
|
|
36
|
+
* },
|
|
37
|
+
* },
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
auto?: boolean | RegExp | ((filename: string) => boolean) | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Allows exporting names from global class names, so you can use them via import.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
*
|
|
47
|
+
* See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#exportglobals | css-loader#exportGlobals} for details.
|
|
48
|
+
*/
|
|
49
|
+
exportGlobals?: boolean | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The style of exported class names.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
*
|
|
55
|
+
* Given the various `exportLocalsConvention` values, the behavior is described as follows:
|
|
56
|
+
*
|
|
57
|
+
* - `'asIs'`: Class names will be exported as is.
|
|
58
|
+
*
|
|
59
|
+
* - `'camelCase'`: Class names will be camelized, the original class name will not to be removed from the locals
|
|
60
|
+
*
|
|
61
|
+
* - `'camelCaseOnly'`: Class names will be camelized, the original class name will be removed from the locals
|
|
62
|
+
*
|
|
63
|
+
* - `'dashes'`: Only dashes in class names will be camelized
|
|
64
|
+
*
|
|
65
|
+
* - `'dashesOnly'`: Dashes in class names will be camelized, the original class name will be removed from the locals
|
|
66
|
+
*
|
|
67
|
+
* See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#exportlocalsconvention | css-loader#exportLocalsConvention} for details.
|
|
68
|
+
*/
|
|
69
|
+
exportLocalsConvention?: CssModuleLocalsConvention | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the format of the className generated by CSS Modules after compilation.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
*
|
|
75
|
+
* See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#localIdentName | css-loader#localIdentName} for details.
|
|
76
|
+
*/
|
|
77
|
+
localIdentName?: string | undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritdoc CssModules.exportLocalsConvention}
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export type CssModuleLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@inheritdoc Output.distPath}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface DistPath {
|
|
7
|
+
/**
|
|
8
|
+
* The root directory of all output files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* Default value:
|
|
13
|
+
*
|
|
14
|
+
* - `'dist'`
|
|
15
|
+
*/
|
|
16
|
+
root?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The output directory of CSS style files.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* Default value:
|
|
23
|
+
*
|
|
24
|
+
* - The same as {@link DistPath.intermediate}
|
|
25
|
+
*/
|
|
26
|
+
css?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The output directory of async JavaScript files.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
*
|
|
32
|
+
* Default value:
|
|
33
|
+
*
|
|
34
|
+
* - The `async` subdirectory of {@link DistPath.css}.
|
|
35
|
+
*/
|
|
36
|
+
cssAsync?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The output directory of the intermediate files.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
*
|
|
42
|
+
* Default value:
|
|
43
|
+
*
|
|
44
|
+
* - `'.rspeedy'`
|
|
45
|
+
*/
|
|
46
|
+
intermediate?: string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The output directory of JavaScript files.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
*
|
|
52
|
+
* Default value:
|
|
53
|
+
*
|
|
54
|
+
* - `'static/js'`
|
|
55
|
+
*/
|
|
56
|
+
js?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The output directory of async JavaScript files.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
*
|
|
62
|
+
* Default value:
|
|
63
|
+
*
|
|
64
|
+
* - The `async` subdirectory of {@link DistPath.js}.
|
|
65
|
+
*/
|
|
66
|
+
jsAsync?: string | undefined;
|
|
67
|
+
}
|
|
68
|
+
export declare const DEFAULT_DIST_PATH_INTERMEDIATE = ".rspeedy";
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@inheritdoc Output.filename}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface Filename {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the bundle files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* Default values:
|
|
13
|
+
*
|
|
14
|
+
* - `'[name].[platform].bundle'`
|
|
15
|
+
*
|
|
16
|
+
* The following placeholder is supported:
|
|
17
|
+
*
|
|
18
|
+
* - `[name]`: the name of the entry.
|
|
19
|
+
* - `[contenthash]`: the contenthash of the bundle.
|
|
20
|
+
* - `[platform]`: the environment name of the bundle.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* - Using content hash in bundle filename:
|
|
25
|
+
*
|
|
26
|
+
* ```js
|
|
27
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
28
|
+
*
|
|
29
|
+
* export default defineConfig({
|
|
30
|
+
* output: {
|
|
31
|
+
* filename: {
|
|
32
|
+
* bundle: '[name].[contenthash].bundle',
|
|
33
|
+
* },
|
|
34
|
+
* },
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* - Using content hash with length in bundle filename:
|
|
41
|
+
*
|
|
42
|
+
* ```js
|
|
43
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
44
|
+
*
|
|
45
|
+
* export default defineConfig({
|
|
46
|
+
* output: {
|
|
47
|
+
* filename: {
|
|
48
|
+
* bundle: '[name].[contenthash:8].bundle',
|
|
49
|
+
* },
|
|
50
|
+
* },
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
bundle?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The name of the template files.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated
|
|
59
|
+
*
|
|
60
|
+
* Use {@link Filename.bundle} instead.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
*
|
|
64
|
+
* Default values:
|
|
65
|
+
*
|
|
66
|
+
* - `'[name].lynx.bundle'`
|
|
67
|
+
*
|
|
68
|
+
* The following placeholder is supported:
|
|
69
|
+
*
|
|
70
|
+
* - `[name]`: the name of the entry.
|
|
71
|
+
* - `[contenthash]`: the contenthash of the template.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
*
|
|
75
|
+
* - Using content hash in bundle filename:
|
|
76
|
+
*
|
|
77
|
+
* ```js
|
|
78
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
79
|
+
*
|
|
80
|
+
* export default defineConfig({
|
|
81
|
+
* output: {
|
|
82
|
+
* filename: {
|
|
83
|
+
* template: '[name].[contenthash].bundle',
|
|
84
|
+
* },
|
|
85
|
+
* },
|
|
86
|
+
* })
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
*
|
|
91
|
+
* - Using content hash with length in bundle filename:
|
|
92
|
+
*
|
|
93
|
+
* ```js
|
|
94
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
95
|
+
*
|
|
96
|
+
* export default defineConfig({
|
|
97
|
+
* output: {
|
|
98
|
+
* filename: {
|
|
99
|
+
* template: '[name].[contenthash:8].bundle',
|
|
100
|
+
* },
|
|
101
|
+
* },
|
|
102
|
+
* })
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
template?: string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The name of the JavaScript files.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
*
|
|
111
|
+
* Default values:
|
|
112
|
+
*
|
|
113
|
+
* - Development: `'[name].js'`
|
|
114
|
+
* - Production: `'[name].[contenthash:8].js'`
|
|
115
|
+
*/
|
|
116
|
+
js?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* The name of the CSS files.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
*
|
|
122
|
+
* Default values:
|
|
123
|
+
*
|
|
124
|
+
* - `'[name].css'`
|
|
125
|
+
*/
|
|
126
|
+
css?: string | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* The name of the SVG images.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
*
|
|
132
|
+
* Default values:
|
|
133
|
+
*
|
|
134
|
+
* - `'[name].[contenthash:8].svg'`
|
|
135
|
+
*/
|
|
136
|
+
svg?: string | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The name of the font files.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
*
|
|
142
|
+
* Default values:
|
|
143
|
+
*
|
|
144
|
+
* - `'[name].[contenthash:8][ext]'`
|
|
145
|
+
*/
|
|
146
|
+
font?: string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* The name of non-SVG images.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
*
|
|
152
|
+
* Default values:
|
|
153
|
+
*
|
|
154
|
+
* - `'[name].[contenthash:8][ext]'`
|
|
155
|
+
*/
|
|
156
|
+
image?: string | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* The name of media assets, such as video.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
*
|
|
162
|
+
* Default values:
|
|
163
|
+
*
|
|
164
|
+
* - `'[name].[contenthash:8][ext]'`
|
|
165
|
+
*/
|
|
166
|
+
media?: string | undefined;
|
|
167
|
+
}
|