Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"magic-string": "^0.25.7",
"minimist": "^1.2.5",
"postcss": "^7.0.27",
"postcss-load-config": "^2.1.0",
"resolve-from": "^5.0.0",
"rollup": "^2.7.2",
"rollup-plugin-terser": "^5.3.0",
Expand All @@ -83,6 +84,7 @@
"@types/hash-sum": "^1.0.0",
"@types/lru-cache": "^5.1.0",
"@types/node": "^13.13.1",
"@types/postcss-load-config": "^2.0.1",
"@types/serve-handler": "^6.1.0",
"@types/ws": "^7.2.4",
"conventional-changelog-cli": "^2.0.31",
Expand Down
14 changes: 11 additions & 3 deletions src/node/serverPluginVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { hmrClientId } from './serverPluginHmr'
import resolve from 'resolve-from'
import { cachedRead } from './utils'
import { Context } from 'koa'

import postcssrc from 'postcss-load-config'
const debug = require('debug')('vite:sfc')
const getEtag = require('etag')

Expand Down Expand Up @@ -250,8 +250,8 @@ async function compileSFCStyle(
scoped: style.scoped != null,
modules: style.module != null,
preprocessLang: style.lang as any,
preprocessCustomRequire: (id: string) => require(resolve(root, id))
// TODO load postcss config if present
preprocessCustomRequire: (id: string) => require(resolve(root, id)),
...loadPostCssConfig(root)
})

if (result.errors.length) {
Expand All @@ -266,3 +266,11 @@ async function compileSFCStyle(
vueCache.set(filePath, cached)
return result
}

function loadPostCssConfig(root: string) {
const config = postcssrc.sync({}, root)
return {
postcssOptions: config.options,
postcssPlugins: config.plugins
}
}
30 changes: 30 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,14 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==

"@types/postcss-load-config@^2.0.1":
version "2.0.1"
resolved "https://registry.npm.taobao.org/@types/postcss-load-config/download/@types/postcss-load-config-2.0.1.tgz#76c789032dfc6823eab1900ad7cc95ebadf24d49"
integrity sha1-dseJAy38aCPqsZAK18yV663yTUk=
dependencies:
cosmiconfig "^6.0.0"
postcss "^7.0.0"

"@types/prettier@^1.19.0":
version "1.19.1"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.1.tgz#33509849f8e679e4add158959fdb086440e9553f"
Expand Down Expand Up @@ -2988,6 +2996,13 @@ ieee754@^1.1.4:
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==

import-cwd@^2.0.0:
version "2.1.0"
resolved "https://registry.npm.taobao.org/import-cwd/download/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
integrity sha1-qmzzbnInYShcs3HsZRn1PiQ1sKk=
dependencies:
import-from "^2.1.0"

import-fresh@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546"
Expand All @@ -3004,6 +3019,13 @@ import-fresh@^3.1.0:
parent-module "^1.0.0"
resolve-from "^4.0.0"

import-from@^2.1.0:
version "2.1.0"
resolved "https://registry.npm.taobao.org/import-from/download/import-from-2.1.0.tgz#335db7f2a7affd53aaa471d4b8021dee36b7f3b1"
integrity sha1-M1238qev/VOqpHHUuAId7ja387E=
dependencies:
resolve-from "^3.0.0"

import-local@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6"
Expand Down Expand Up @@ -5039,6 +5061,14 @@ postcss-discard-overridden@^4.0.1:
dependencies:
postcss "^7.0.0"

postcss-load-config@^2.1.0:
version "2.1.0"
resolved "https://registry.npm.taobao.org/postcss-load-config/download/postcss-load-config-2.1.0.tgz#c84d692b7bb7b41ddced94ee62e8ab31b417b003"
integrity sha1-yE1pK3u3tB3c7ZTuYuirMbQXsAM=
dependencies:
cosmiconfig "^5.0.0"
import-cwd "^2.0.0"

postcss-merge-longhand@^4.0.11:
version "4.0.11"
resolved "https://registry.yarnpkg.com/postcss-merge-longhand/-/postcss-merge-longhand-4.0.11.tgz#62f49a13e4a0ee04e7b98f42bb16062ca2549e24"
Expand Down