feat: allow lang="postcss" in Vue SFCs (#4417)

* fix: allow postcss lang as tag

* refactor: own postcss rule
This commit is contained in:
Alexander Lichter 2018-11-30 15:23:44 +00:00 committed by Sébastien Chopin
parent 8baf574254
commit 71136fc9b6
3 changed files with 32 additions and 0 deletions

View File

@ -198,6 +198,10 @@ export default class WebpackBaseConfig {
test: /\.css$/, test: /\.css$/,
oneOf: styleLoader.apply('css') oneOf: styleLoader.apply('css')
}, },
{
test: /\.postcss$/,
oneOf: styleLoader.apply('postcss')
},
{ {
test: /\.less$/, test: /\.less$/,
oneOf: styleLoader.apply('less', { oneOf: styleLoader.apply('less', {

15
test/fixtures/basic/pages/postcss.vue vendored Normal file
View File

@ -0,0 +1,15 @@
<template>
<div class="red">
This is red
</div>
</template>
<style lang="postcss">
@custom-selector :--red div.red;
:--red {
background-color: blue;
}
.red {
color: red;
}
</style>

View File

@ -40,6 +40,19 @@ describe('basic ssr', () => {
// t.is(window.getComputedStyle(element).color, 'red') // t.is(window.getComputedStyle(element).color, 'red')
}) })
test('/postcss', async () => {
const window = await nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
expect(headHtml).toContain('color:red')
const element = window.document.querySelector('.red')
expect(element).not.toBe(null)
expect(element.textContent).toContain('This is red')
expect(element.className).toBe('red')
// t.is(window.getComputedStyle(element).color, 'red')
})
test('/postcss', async () => { test('/postcss', async () => {
const window = await nuxt.server.renderAndGetWindow(url('/css')) const window = await nuxt.server.renderAndGetWindow(url('/css'))