Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency postcss-import to v15 #9929

Merged
merged 3 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"parse5": "^7.0.0",
"periscopic": "^3.0.4",
"picocolors": "^1.0.0",
"postcss-import": "^14.1.0",
"postcss-import": "^15.0.0",
"postcss-load-config": "^4.0.1",
"postcss-modules": "^5.0.0",
"resolve.exports": "^1.1.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@ async function compileCSS(
return path.resolve(resolved)
}
return id
},
nameLayer(index) {
return `vite--anon-layer-${getHash(id)}-${index}`
}
})
)
Expand Down
1 change: 1 addition & 0 deletions packages/vite/types/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ declare module 'postcss-import' {
basedir: string,
importOptions: any
) => string | string[] | Promise<string | string[]>
nameLayer: (index: number, rootFilename: string) => string
}) => Plugin
export = plugin
}
Expand Down
5 changes: 5 additions & 0 deletions playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ test.runIf(isBuild)('@charset hoist', async () => {
})
})

test('layers', async () => {
expect(await getColor('.layers-blue')).toMatch('blue')
expect(await getColor('.layers-green')).toMatch('green')
})

test('@import dependency w/ style entry', async () => {
expect(await getColor('.css-dep')).toBe('purple')
})
Expand Down
6 changes: 6 additions & 0 deletions playground/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ <h1>CSS</h1>
<p>CSS with @charset:</p>
<pre class="charset-css"></pre>

<p>
@import with layers:
<span class="layers-blue">blue</span>
<span class="layers-green">green</span>
</p>

<p class="css-dep">
@import dependency w/ style entrypoints: this should be purple
</p>
Expand Down
5 changes: 5 additions & 0 deletions playground/css/layered/blue.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media screen {
.layers-blue {
color: blue;
}
}
5 changes: 5 additions & 0 deletions playground/css/layered/green.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media screen {
.layers-green {
color: green;
}
}
13 changes: 13 additions & 0 deletions playground/css/layered/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@layer base;

@import './blue.css' layer;
@import './green.css' layer;

@layer base {
.layers-blue {
color: black;
}
.layers-green {
color: black;
}
}
2 changes: 2 additions & 0 deletions playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ text('.modules-inline', inlineMod)
import charset from './charset.css'
text('.charset-css', charset)

import './layered/index.css'

import './dep.css'
import './glob-dep.css'

Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

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