-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
98 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { | ||
RsbuildTarget, | ||
NormalizedConfig, | ||
FilenameConfig, | ||
} from '@rsbuild/core'; | ||
|
||
export const RUNTIME_CHUNK_NAME = 'builder-runtime'; | ||
|
||
export const TS_REGEX = /\.(?:ts|mts|cts|tsx)$/; | ||
|
||
export function isServerTarget(target: RsbuildTarget[]) { | ||
return (Array.isArray(target) ? target : [target]).some(item => | ||
['node', 'service-worker'].includes(item), | ||
); | ||
} | ||
|
||
export function getFilename( | ||
config: NormalizedConfig, | ||
type: 'js', | ||
isProd: boolean, | ||
): NonNullable<FilenameConfig['js']>; | ||
export function getFilename( | ||
config: NormalizedConfig, | ||
type: Exclude<keyof FilenameConfig, 'js'>, | ||
isProd: boolean, | ||
): string; | ||
export function getFilename( | ||
config: NormalizedConfig, | ||
type: keyof FilenameConfig, | ||
isProd: boolean, | ||
) { | ||
const { filename, filenameHash } = config.output; | ||
|
||
const getHash = () => { | ||
if (typeof filenameHash === 'string') { | ||
return filenameHash ? `.[${filenameHash}]` : ''; | ||
} | ||
return filenameHash ? '.[contenthash:8]' : ''; | ||
}; | ||
|
||
const hash = getHash(); | ||
|
||
switch (type) { | ||
case 'js': | ||
return filename.js ?? `[name]${isProd ? hash : ''}.js`; | ||
case 'css': | ||
return filename.css ?? `[name]${isProd ? hash : ''}.css`; | ||
case 'svg': | ||
return filename.svg ?? `[name]${hash}.svg`; | ||
case 'font': | ||
return filename.font ?? `[name]${hash}[ext]`; | ||
case 'image': | ||
return filename.image ?? `[name]${hash}[ext]`; | ||
case 'media': | ||
return filename.media ?? `[name]${hash}[ext]`; | ||
default: | ||
throw new Error(`unknown key ${type} in "output.filename"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/cli/uni-builder/src/webpack/plugins/styledComponents.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters