Skip to content

Commit

Permalink
fix: fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
stygian-desolator committed Feb 15, 2022
1 parent 68de7cb commit a88234c
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -55,10 +55,10 @@ export interface CSSOptions {
modules?: CSSModulesOptions | false
preprocessorOptions?: Record<string, any>
postcss?:
| string
| (Postcss.ProcessOptions & {
plugins?: Postcss.Plugin[]
})
| string
| (Postcss.ProcessOptions & {
plugins?: Postcss.Plugin[]
})
}

export interface CSSModulesOptions {
Expand All @@ -70,18 +70,18 @@ export interface CSSModulesOptions {
scopeBehaviour?: 'global' | 'local'
globalModulePaths?: RegExp[]
generateScopedName?:
| string
| ((name: string, filename: string, css: string) => string)
| string
| ((name: string, filename: string, css: string) => string)
hashPrefix?: string
/**
* default: null
*/
localsConvention?:
| 'camelCase'
| 'camelCaseOnly'
| 'dashes'
| 'dashesOnly'
| null
| 'camelCase'
| 'camelCaseOnly'
| 'dashes'
| 'dashesOnly'
| null
}

const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`
Expand Down Expand Up @@ -221,14 +221,14 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
isCSSRequest(file)
? moduleGraph.createFileOnlyEntry(file)
: await moduleGraph.ensureEntryFromUrl(
(
await fileToUrl(file, config, this)
).replace(
(config.server?.origin ?? '') + config.base,
'/'
),
ssr
)
(
await fileToUrl(file, config, this)
).replace(
(config.server?.origin ?? '') + config.base,
'/'
),
ssr
)
)
}
moduleGraph.updateModuleInfo(
Expand Down Expand Up @@ -314,9 +314,8 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
`const __vite__css = ${JSON.stringify(css)}`,
`__vite__updateStyle(__vite__id, __vite__css)`,
// css modules exports change on edit so it can't self accept
`${
modulesCode ||
`import.meta.hot.accept()\nexport default __vite__css`
`${modulesCode ||
`import.meta.hot.accept()\nexport default __vite__css`
}`,
`import.meta.hot.prune(() => __vite__removeStyle(__vite__id))`
].join('\n')
Expand Down Expand Up @@ -347,8 +346,8 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
modulesCode ||
(usedRE.test(id)
? `export default ${JSON.stringify(
inlined ? await minifyCSS(css, config) : css
)}`
inlined ? await minifyCSS(css, config) : css
)}`
: `export default ''`),
map: { mappings: '' },
// avoid the css module from being tree-shaken so that we can retrieve
Expand Down

0 comments on commit a88234c

Please sign in to comment.