Skip to content

Commit 09c0137

Browse files
committed
update postcss dependencies
1 parent 5596ca9 commit 09c0137

4 files changed

Lines changed: 75 additions & 43 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
"xo": "^0.18.2"
4444
},
4545
"dependencies": {
46-
"chalk": "^2.0.0",
46+
"chalk": "^2.4.2",
4747
"concat-with-sourcemaps": "^1.0.5",
48-
"cssnano": "^4.1.5",
48+
"cssnano": "^4.1.8",
4949
"import-cwd": "^2.1.0",
5050
"p-queue": "^2.4.2",
5151
"pify": "^3.0.0",
52-
"postcss": "^6.0.21",
53-
"postcss-load-config": "^1.2.0",
52+
"postcss": "^7.0.14",
53+
"postcss-load-config": "^2.0.0",
5454
"postcss-modules": "^1.4.1",
5555
"promise.series": "^0.2.0",
5656
"reserved-words": "^0.1.2",

src/postcss-loader.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function loadConfig(id, { ctx: configOptions, path: configPath }) {
2929
options: configOptions || {}
3030
}
3131

32-
return findPostcssConfig(ctx, configPath, { argv: false }).catch(handleError)
32+
return findPostcssConfig(ctx, configPath).catch(handleError)
3333
}
3434

3535
function escapeClassNameDashes(str) {
@@ -59,9 +59,9 @@ export default {
5959
alwaysProcess: true,
6060
// `test` option is dynamically set in ./loaders
6161
async process({ code, map }) {
62-
const config = this.options.config ?
63-
await loadConfig(this.id, this.options.config) :
64-
{}
62+
const config = this.options.config
63+
? await loadConfig(this.id, this.options.config)
64+
: {}
6565

6666
const options = this.options
6767
const plugins = [
@@ -79,9 +79,9 @@ export default {
7979
require('postcss-modules')({
8080
// In tests
8181
// Skip hash in names since css content on windows and linux would differ because of `new line` (\r?\n)
82-
generateScopedName: process.env.ROLLUP_POSTCSS_TEST ?
83-
'[name]_[local]' :
84-
'[name]_[local]__[hash:base64:5]',
82+
generateScopedName: process.env.ROLLUP_POSTCSS_TEST
83+
? '[name]_[local]'
84+
: '[name]_[local]__[hash:base64:5]',
8585
...options.modules,
8686
getJSON(filepath, json, outpath) {
8787
modulesExported[filepath] = json
@@ -107,11 +107,11 @@ export default {
107107
// Followings are never modified by user config config
108108
from: this.id,
109109
to: this.id,
110-
map: this.sourceMap ?
111-
shouldExtract ?
112-
{ inline: false, annotation: false } :
113-
{ inline: true, annotation: false } :
114-
false
110+
map: this.sourceMap
111+
? shouldExtract
112+
? { inline: false, annotation: false }
113+
: { inline: true, annotation: false }
114+
: false
115115
}
116116
delete postcssOpts.plugins
117117

@@ -123,6 +123,15 @@ export default {
123123
postcssOpts.map.prev = typeof map === 'string' ? JSON.parse(map) : map
124124
}
125125

126+
if (plugins.length === 0) {
127+
// Prevent from postcss warning:
128+
// You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js
129+
const noopPlugin = postcss.plugin('postcss-noop-plugin', () => () => {
130+
/* noop */
131+
})
132+
plugins.push(noopPlugin())
133+
}
134+
126135
const res = await postcss(plugins).process(code, postcssOpts)
127136

128137
for (const msg of res.messages) {
@@ -146,9 +155,9 @@ export default {
146155
if (options.namedExports) {
147156
const json = modulesExported[this.id]
148157
const getClassName =
149-
typeof options.namedExports === 'function' ?
150-
options.namedExports :
151-
ensureClassName
158+
typeof options.namedExports === 'function'
159+
? options.namedExports
160+
: ensureClassName
152161
// eslint-disable-next-line guard-for-in
153162
for (const name in json) {
154163
const newName = getClassName(name)
@@ -181,9 +190,9 @@ export default {
181190
}
182191
if (!shouldExtract && shouldInject) {
183192
output += `\nimport styleInject from '${styleInjectPath}';\nstyleInject(css${
184-
Object.keys(options.inject).length > 0 ?
185-
`,${JSON.stringify(options.inject)}` :
186-
''
193+
Object.keys(options.inject).length > 0
194+
? `,${JSON.stringify(options.inject)}`
195+
: ''
187196
});`
188197
}
189198

0 commit comments

Comments
 (0)