forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css): add cssExtract option to build config (vitejs#4345)
- Loading branch information
1 parent
4a764f5
commit 8200b5f
Showing
13 changed files
with
96 additions
and
27 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/playground/css-extract/__tests__/css-extract.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { findAssetFile, getColor, isBuild } from '../../testUtils' | ||
|
||
test('should load both stylesheets', async () => { | ||
expect(await getColor('h1')).toBe('red') | ||
expect(await getColor('h2')).toBe('blue') | ||
}) | ||
|
||
if (isBuild) { | ||
test('should generate correct files', async () => { | ||
expect(findAssetFile(/style.*\.js$/)).toMatch('h2{color') | ||
expect(findAssetFile('main.*.js$')).toMatch('h1{color') | ||
|
||
const bothImportStyle = findAssetFile('other.*.js$').replace('\n', '') | ||
expect(findAssetFile('main.*.js$')).toMatch(bothImportStyle) | ||
}) | ||
} |
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,2 @@ | ||
<script type="module" src="/main.js"></script> | ||
<div id="app"></div> |
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,3 @@ | ||
h1 { | ||
color: red; | ||
} |
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,6 @@ | ||
import './style.css' | ||
import './main.css' | ||
|
||
document.getElementById( | ||
'app' | ||
).innerHTML = `<h1>This should be red</h1><h2>This should be blue</h2>` |
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 @@ | ||
import './style.css' |
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,11 @@ | ||
{ | ||
"name": "test-css-css-extract", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../vite/bin/vite", | ||
"preview": "vite preview" | ||
} | ||
} |
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,3 @@ | ||
h2 { | ||
color: blue; | ||
} |
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,14 @@ | ||
const { resolve } = require('path') | ||
|
||
module.exports = { | ||
build: { | ||
manifest: true, | ||
cssExtract: false, | ||
rollupOptions: { | ||
input: { | ||
main: resolve(__dirname, './index.html'), | ||
other: resolve(__dirname, './other.js') | ||
} | ||
} | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
packages/playground/nested-deps/test-package-b/node_modules/test-package-a/index.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/playground/nested-deps/test-package-b/node_modules/test-package-a/package.json
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.