Skip to content

Commit

Permalink
test: add vitejs#8461 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jul 1, 2022
1 parent 656e26f commit 2c5aca0
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ test('PostCSS dir-dependency', async () => {
}
})

test('import dependency includes css import', async () => {
expect(await getColor('.css-js-dep')).toBe('green')
expect(await getColor('.css-js-dep-module')).toBe('green')
})

test('URL separation', async () => {
const urlSeparated = await page.$('.url-separated')
const baseUrl = 'url(images/dog.webp)'
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/css/css-js-dep/bar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cssJsDepModule {
color: green;
}
3 changes: 3 additions & 0 deletions packages/playground/css/css-js-dep/foo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.css-js-dep {
color: green;
}
4 changes: 4 additions & 0 deletions packages/playground/css/css-js-dep/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './foo.css'
import barModuleClasses from './bar.module.css'

export { barModuleClasses }
7 changes: 7 additions & 0 deletions packages/playground/css/css-js-dep/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "css-js-dep",
"private": true,
"type": "module",
"version": "1.0.0",
"main": "index.js"
}
7 changes: 7 additions & 0 deletions packages/playground/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ <h1>CSS</h1>
PostCSS dir-dependency (file 2): this should be grey too
</p>

<p class="css-js-dep">
import dependency includes 'import "./foo.css"': this should be green
</p>
<p class="css-js-dep-module">
import dependency includes 'import "./bar.module.css"': this should be green
</p>

<p class="url-separated">
URL separation preservation: should have valid background-image
</p>
Expand Down
5 changes: 5 additions & 0 deletions packages/playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ text('.charset-css', charset)
import './dep.css'
import './glob-dep.css'

import { barModuleClasses } from 'css-js-dep'
document
.querySelector('.css-js-dep-module')
.classList.add(barModuleClasses.cssJsDepModule)

function text(el, text) {
document.querySelector(el).textContent = text
}
Expand Down
6 changes: 5 additions & 1 deletion packages/playground/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../vite/bin/vite",
"preview": "vite preview"
"preview": "vite preview",
"postinstall": "ts-node ../../../scripts/patchFileDeps.ts"
},
"dependencies": {
"css-js-dep": "file:./css-js-dep"
},
"devDependencies": {
"css-dep": "link:./css-dep",
Expand Down
8 changes: 7 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c5aca0

Please sign in to comment.