Skip to content

Commit a334c56

Browse files
committed
test: postcss integration
1 parent 3175633 commit a334c56

File tree

7 files changed

+136
-19
lines changed

7 files changed

+136
-19
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444
"lint-staged": "^7.0.0",
4545
"node-sass": "^4.7.2",
4646
"normalize-newline": "^3.0.0",
47+
"postcss-loader": "^2.1.2",
4748
"pug": "^2.0.1",
4849
"sass-loader": "^6.0.7",
4950
"stylus": "^0.54.5",
5051
"stylus-loader": "^3.0.2",
52+
"sugarss": "^1.0.1",
5153
"vue": "^2.5.16",
5254
"vue-template-compiler": "^2.5.16",
5355
"webpack": "^4.1.0",

test/fixtures/postcss-lang.vue

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/fixtures/postcss.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<style>
1+
<style lang="postcss" scoped>
22
h1
33
color: red
44
font-size: 14px

test/fixtures/sub/.postcssrc.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/fixtures/sub/postcss-cascade.vue

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/style.spec.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,78 @@ test('supports-query', done => {
7676
done()
7777
})
7878
})
79+
80+
test('postcss', done => {
81+
mockBundleAndRun({
82+
entry: 'postcss.vue',
83+
module: {
84+
rules: [
85+
{
86+
test: /\.postcss$/,
87+
use: [
88+
'vue-style-loader',
89+
'css-loader',
90+
{
91+
loader: 'postcss-loader',
92+
options: {
93+
parser: require('sugarss')
94+
}
95+
}
96+
]
97+
}
98+
]
99+
}
100+
}, ({ window }) => {
101+
const id = 'data-v-' + genId('postcss.vue')
102+
let style = window.document.querySelector('style').textContent
103+
style = normalizeNewline(style)
104+
expect(style).toContain(`h1[${id}] {\n color: red;\n font-size: 14px\n}`)
105+
done()
106+
})
107+
})
108+
109+
// test('css-modules', done => {
110+
// function testWithIdent (localIdentName, regexToMatch, cb) {
111+
// mockBundleAndRun({
112+
// entry: 'css-modules.vue',
113+
// vue: {
114+
// cssModules: localIdentName && {
115+
// localIdentName: localIdentName
116+
// }
117+
// }
118+
// }, (window, module, raw, instance) => {
119+
// // get local class name
120+
// const className = instance.style.red
121+
// expect(className).toMatch(regexToMatch)
122+
123+
// // class name in style
124+
// let style = [].slice.call(window.document.querySelectorAll('style')).map((style) => {
125+
// return style.textContent
126+
// }).join('\n')
127+
// style = normalizeNewline(style)
128+
// expect(style).toContain('.' + className + ' {\n color: red;\n}')
129+
130+
// // animation name
131+
// const match = style.match(/@keyframes\s+(\S+)\s+{/)
132+
// expect(match).toHaveLength(2)
133+
// const animationName = match[1]
134+
// expect(animationName).not.toBe('fade')
135+
// expect(style).toContain('animation: ' + animationName + ' 1s;')
136+
137+
// // default module + pre-processor + scoped
138+
// const anotherClassName = instance.$style.red
139+
// expect(anotherClassName).to.match(regexToMatch).not.toBe(className)
140+
// const id = 'data-v-' + genId('css-modules.vue')
141+
// expect(style).toContain('.' + anotherClassName + '[' + id + ']')
142+
143+
// cb()
144+
// })
145+
// }
146+
// // default localIdentName
147+
// testWithIdent(undefined, /^red_\w{8}/, () => {
148+
// // specified localIdentName
149+
// const ident = '[path][name]---[local]---[hash:base64:5]'
150+
// const regex = /css-modules---red---\w{5}/
151+
// testWithIdent(ident, regex, done)
152+
// })
153+
// })

yarn.lock

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,18 @@ [email protected], core-util-is@~1.0.0:
17061706
version "1.0.2"
17071707
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
17081708

1709+
cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
1710+
version "2.2.2"
1711+
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-2.2.2.tgz#6173cebd56fac042c1f4390edf7af6c07c7cb892"
1712+
dependencies:
1713+
is-directory "^0.3.1"
1714+
js-yaml "^3.4.3"
1715+
minimist "^1.2.0"
1716+
object-assign "^4.1.0"
1717+
os-homedir "^1.0.1"
1718+
parse-json "^2.2.0"
1719+
require-from-string "^1.1.0"
1720+
17091721
cosmiconfig@^4.0.0:
17101722
version "4.0.0"
17111723
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc"
@@ -4090,7 +4102,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2:
40904102
version "3.0.2"
40914103
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
40924104

4093-
js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1:
4105+
js-yaml@^3.4.3, js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1:
40944106
version "3.11.0"
40954107
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
40964108
dependencies:
@@ -5107,7 +5119,7 @@ os-browserify@^0.3.0:
51075119
version "0.3.0"
51085120
resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27"
51095121

5110-
os-homedir@^1.0.0:
5122+
os-homedir@^1.0.0, os-homedir@^1.0.1:
51115123
version "1.0.2"
51125124
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
51135125

@@ -5421,6 +5433,38 @@ postcss-filter-plugins@^2.0.0:
54215433
postcss "^5.0.4"
54225434
uniqid "^4.0.0"
54235435

5436+
postcss-load-config@^1.2.0:
5437+
version "1.2.0"
5438+
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-1.2.0.tgz#539e9afc9ddc8620121ebf9d8c3673e0ce50d28a"
5439+
dependencies:
5440+
cosmiconfig "^2.1.0"
5441+
object-assign "^4.1.0"
5442+
postcss-load-options "^1.2.0"
5443+
postcss-load-plugins "^2.3.0"
5444+
5445+
postcss-load-options@^1.2.0:
5446+
version "1.2.0"
5447+
resolved "https://registry.yarnpkg.com/postcss-load-options/-/postcss-load-options-1.2.0.tgz#b098b1559ddac2df04bc0bb375f99a5cfe2b6d8c"
5448+
dependencies:
5449+
cosmiconfig "^2.1.0"
5450+
object-assign "^4.1.0"
5451+
5452+
postcss-load-plugins@^2.3.0:
5453+
version "2.3.0"
5454+
resolved "https://registry.yarnpkg.com/postcss-load-plugins/-/postcss-load-plugins-2.3.0.tgz#745768116599aca2f009fad426b00175049d8d92"
5455+
dependencies:
5456+
cosmiconfig "^2.1.1"
5457+
object-assign "^4.1.0"
5458+
5459+
postcss-loader@^2.1.2:
5460+
version "2.1.2"
5461+
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-2.1.2.tgz#03f54e23be736c9ea4f610e17d2a299254c05130"
5462+
dependencies:
5463+
loader-utils "^1.1.0"
5464+
postcss "^6.0.0"
5465+
postcss-load-config "^1.2.0"
5466+
schema-utils "^0.4.0"
5467+
54245468
postcss-merge-idents@^2.1.5:
54255469
version "2.1.7"
54265470
resolved "https://registry.yarnpkg.com/postcss-merge-idents/-/postcss-merge-idents-2.1.7.tgz#4c5530313c08e1d5b3bbf3d2bbc747e278eea270"
@@ -5617,7 +5661,7 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0
56175661
source-map "^0.5.6"
56185662
supports-color "^3.2.3"
56195663

5620-
postcss@^6.0.1, postcss@^6.0.12, postcss@^6.0.20:
5664+
postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.12, postcss@^6.0.14, postcss@^6.0.20:
56215665
version "6.0.20"
56225666
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.20.tgz#686107e743a12d5530cb68438c590d5b2bf72c3c"
56235667
dependencies:
@@ -6192,6 +6236,10 @@ require-directory@^2.1.1:
61926236
version "2.1.1"
61936237
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
61946238

6239+
require-from-string@^1.1.0:
6240+
version "1.2.1"
6241+
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-1.2.1.tgz#529c9ccef27380adfec9a2f965b649bbee636418"
6242+
61956243
require-from-string@^2.0.1:
61966244
version "2.0.1"
61976245
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff"
@@ -6372,7 +6420,7 @@ sax@^1.2.4, sax@~1.2.1:
63726420
version "1.2.4"
63736421
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
63746422

6375-
schema-utils@^0.4.2:
6423+
schema-utils@^0.4.0, schema-utils@^0.4.2:
63766424
version "0.4.5"
63776425
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.5.tgz#21836f0608aac17b78f9e3e24daff14a5ca13a3e"
63786426
dependencies:
@@ -6852,6 +6900,12 @@ stylus@^0.54.5:
68526900
sax "0.5.x"
68536901
source-map "0.1.x"
68546902

6903+
sugarss@^1.0.1:
6904+
version "1.0.1"
6905+
resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-1.0.1.tgz#be826d9003e0f247735f92365dc3fd7f1bae9e44"
6906+
dependencies:
6907+
postcss "^6.0.14"
6908+
68556909
superstruct@^0.5.0:
68566910
version "0.5.1"
68576911
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.5.1.tgz#cd6ddd7e5ad453440b14c60b9f8264b17fc88e75"

0 commit comments

Comments
 (0)