Skip to content

Commit 88e6fe0

Browse files
committed
Fix type in CSS plugin
1 parent 5a0d041 commit 88e6fe0

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

programs/develop/webpack/plugin-css/css-in-content-script-loader.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ export async function cssInContentScriptLoader(
99
) {
1010
const manifestPath = path.join(projectPath, 'manifest.json')
1111

12-
return [{
13-
test: /\.css$/,
14-
type: 'asset',
15-
generator: {
16-
// Add contenthash to avoid naming collisions between
17-
// different content script CSS files
18-
filename: 'content_scripts/[name].[contenthash:8].css'
19-
},
20-
issuer: (issuer: string) => isContentScriptEntry(issuer, manifestPath),
21-
use: await commonStyleLoaders(projectPath, {
22-
mode: mode as 'development' | 'production'
23-
})
24-
}]
12+
return [
13+
{
14+
test: /\.css$/,
15+
type: 'asset',
16+
generator: {
17+
// Add contenthash to avoid naming collisions between
18+
// different content script CSS files
19+
filename: 'content_scripts/[name].[contenthash:8].css'
20+
},
21+
issuer: (issuer: string) => isContentScriptEntry(issuer, manifestPath),
22+
use: await commonStyleLoaders(projectPath, {
23+
mode: mode as 'development' | 'production'
24+
})
25+
}
26+
]
2527
}

programs/develop/webpack/plugin-css/css-in-html-loader.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ export async function cssInHtmlLoader(
99
) {
1010
const manifestPath = path.join(projectPath, 'manifest.json')
1111

12-
return {
13-
test: /\.css$/,
14-
type: 'css',
15-
// type: 'css' breaks content scripts so let's avoid it
16-
issuer: (issuer: string) => !isContentScriptEntry(issuer, manifestPath),
17-
use: await commonStyleLoaders(projectPath, {
18-
mode: mode as 'development' | 'production'
19-
})
20-
}
12+
return [
13+
{
14+
test: /\.css$/,
15+
type: 'css',
16+
// type: 'css' breaks content scripts so let's avoid it
17+
issuer: (issuer: string) => !isContentScriptEntry(issuer, manifestPath),
18+
use: await commonStyleLoaders(projectPath, {
19+
mode: mode as 'development' | 'production'
20+
})
21+
}
22+
]
2123
}

programs/develop/webpack/plugin-css/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export class CssPlugin {
3737
// For HTML we need to use the css loader because it's a HTML file
3838
// and we need to load it as a CSS file.
3939
const loaders: RuleSetRule[] = [
40-
await cssInContentScriptLoader(projectPath, mode),
41-
await cssInHtmlLoader(projectPath, mode)
40+
...(await cssInContentScriptLoader(projectPath, mode)),
41+
...(await cssInHtmlLoader(projectPath, mode))
4242
]
4343

4444
// Add Sass/Less support if needed

programs/develop/webpack/webpack-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export default function webpackConfig(
4747
? 'gecko-based'
4848
: devOptions.browser
4949

50+
// Keep hot updates for content scripts in development mode
5051
const cleanConfig = devOptions.output?.clean
5152
? devOptions.output.clean
52-
// Keep hot updates for content scripts in development mode
5353
: devOptions.mode === 'development'
5454

5555
return {

0 commit comments

Comments
 (0)