Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 28648fa

Browse files
committed
Remove extract css options
1 parent 98c6ac6 commit 28648fa

File tree

6 files changed

+5
-45
lines changed

6 files changed

+5
-45
lines changed

framework/react/components/StyleLink.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import { inDeno } from '../helper.ts'
55
const useIsomorphicLayoutEffect = inDeno ? useEffect : useLayoutEffect
66

77
export default function StyleLink({ href }: { href: string }) {
8-
useIsomorphicLayoutEffect(() => {
8+
if (!inDeno) {
99
recoverCSS(href)
10+
}
11+
12+
useIsomorphicLayoutEffect(() => {
1013
return () => removeCSS(href, true)
1114
}, [])
1215

plugins/css.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,6 @@ export const cssLoader = async ({ specifier, data }: LoadInput, aleph: Aleph): P
133133
return { type: 'css', code: css }
134134
}
135135

136-
const { extract: { limit = 8 * 1024 } } = cssConfig
137-
if (css.length > limit) {
138-
const ext = extname(specifier)
139-
const hash = computeHash(css).slice(0, 8)
140-
const path = util.trimSuffix(isRemote ? toLocalPath(specifier) : specifier, ext) + '.' + hash + ext
141-
await aleph.addDist(path, (new TextEncoder).encode(css))
142-
return {
143-
code: [
144-
`import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"`,
145-
`export const href = ${JSON.stringify('/_aleph/' + util.trimPrefix(path, '/'))}`,
146-
`export default ${JSON.stringify(modulesJSON)}`,
147-
`applyCSS(${JSON.stringify(specifier)}, { href })`
148-
].join('\n'),
149-
// todo: generate map
150-
}
151-
}
152-
153136
return {
154137
code: [
155138
`import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"`,

plugins/css_test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,6 @@ Deno.test('plugin: css loader', async () => {
2828
assert(!isCSS('/style/index.sass'))
2929
})
3030

31-
Deno.test('plugin: css loader with extract size option', async () => {
32-
Deno.env.set('DENO_TESTING', 'true')
33-
const dir = await Deno.makeTempDir({ prefix: 'aleph_plugin_testing' })
34-
const aleph = new Aleph(dir, 'development')
35-
aleph.config.css.extract = { limit: 10 }
36-
await ensureTextFile(
37-
join(dir, '/style/index.css'),
38-
'h1 { font-size: 18px; }'
39-
)
40-
const { code } = await cssLoader({ specifier: '/style/index.css', }, aleph)
41-
const distPath = `/style/index.${computeHash('h1 { font-size: 18px; }').slice(0, 8)}.css`
42-
assertEquals(code, [
43-
'import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"',
44-
`export const href = "/_aleph${distPath}"`,
45-
'export default {}',
46-
'applyCSS("/style/index.css", { href })',
47-
].join('\n'))
48-
assert(await exists(join(aleph.buildDir, distPath)))
49-
})
50-
5131
Deno.test('plugin: css loader for remote external', async () => {
5232
Deno.env.set('DENO_TESTING', 'true')
5333
const dir = await Deno.makeTempDir({ prefix: 'aleph_plugin_testing' })

server/aleph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ export class Aleph implements IAleph {
13041304
}
13051305
depModule = mod
13061306
}
1307-
if (!ignoreDeps && depModule) {
1307+
if (depModule) {
13081308
const hash = depModule.hash || depModule.sourceHash
13091309
if (hashLoc !== undefined) {
13101310
if (await this.replaceDepHash(module, hashLoc, hash)) {

server/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ export function defaultConfig(): Readonly<RequiredConfig> {
3131
css: {
3232
cache: true,
3333
modules: {},
34-
extract: {
35-
limit: 8 * 1024
36-
},
3734
postcss: { plugins: ['autoprefixer'] },
3835
},
3936
server: {
@@ -131,7 +128,6 @@ export async function loadConfig(specifier: string): Promise<Config> {
131128
}
132129
config.css = {
133130
cache,
134-
extract: util.isPlainObject(extract) && typeof extract.limit === 'number' ? extract as any : { limit: 8 * 1024 },
135131
modules: util.isPlainObject(modules) ? modules : {},
136132
postcss: isPostcssConfig(postcss) ? postcss : { plugins: ['autoprefixer'] }
137133
}

types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ export type ImportMap = {
187187
export type CSSOptions = {
188188
/** `cache` caches remote css to local if it is true. */
189189
cache?: boolean | RegExp | RegExp[]
190-
/** `extract` specifies the extract options (default is true with 8k limit). */
191-
extract?: { limit: number }
192190
/** `postcss` specifies the postcss plugins. */
193191
postcss?: { plugins: PostCSSPlugin[] }
194192
/** `modules` specifies CSS modules behavior. */

0 commit comments

Comments
 (0)