Skip to content

Commit

Permalink
Update to PostCSS 8. (#17415)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 21, 2020
1 parent 80bf81a commit b89d417
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
@@ -1,12 +1,12 @@
import postcss from 'postcss'
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve'

export function getGlobalCssLoader(
ctx: ConfigurationContext,
postCssPlugins: readonly postcss.AcceptedPlugin[],
postCssPlugins: readonly AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
Expand Down
@@ -1,4 +1,4 @@
import postcss from 'postcss'
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
Expand All @@ -7,7 +7,7 @@ import { getCssModuleLocalIdent } from './getCssModuleLocalIdent'

export function getCssModuleLoader(
ctx: ConfigurationContext,
postCssPlugins: readonly postcss.AcceptedPlugin[],
postCssPlugins: readonly AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
Expand Down
19 changes: 11 additions & 8 deletions packages/next/build/webpack/plugins/css-minimizer-plugin.ts
@@ -1,4 +1,5 @@
import { process as minify } from 'cssnano-simple'
import cssnanoSimple from 'cssnano-simple'
import postcss from 'postcss'
import webpack from 'webpack'
import sources from 'webpack-sources'

Expand Down Expand Up @@ -41,13 +42,15 @@ export class CssMinimizerPlugin {
input = asset.source()
}

return minify(input, postcssOptions).then((res) => {
if (res.map) {
return new SourceMapSource(res.css, file, res.map.toJSON())
} else {
return new RawSource(res.css)
}
})
return postcss([cssnanoSimple])
.process(input, postcssOptions)
.then((res) => {
if (res.map) {
return new SourceMapSource(res.css, file, res.map.toJSON())
} else {
return new RawSource(res.css)
}
})
}

apply(compiler: webpack.Compiler) {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Expand Up @@ -103,7 +103,7 @@
"node-html-parser": "^1.2.19",
"path-browserify": "1.0.1",
"pnp-webpack-plugin": "1.6.4",
"postcss": "7.0.32",
"postcss": "8.1.1",
"process": "0.11.10",
"prop-types": "15.7.2",
"react-is": "16.13.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/types/misc.d.ts
Expand Up @@ -3,8 +3,8 @@ declare module '@babel/plugin-transform-modules-commonjs'
declare module '@babel/plugin-syntax-jsx'
declare module 'browserslist'
declare module 'cssnano-simple' {
import { Plugin } from 'postcss'
const cssnanoSimple: Plugin<{}>
import { OldPlugin } from 'postcss'
const cssnanoSimple: OldPlugin<{}>
export = cssnanoSimple
}
declare module 'styled-jsx/server'
Expand Down
28 changes: 28 additions & 0 deletions yarn.lock
Expand Up @@ -5388,6 +5388,11 @@ color@^3.1.2:
color-convert "^1.9.1"
color-string "^1.5.4"

colorette@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b"
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==

colormin@^1.0.5:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colormin/-/colormin-1.1.2.tgz#ea2f7420a72b96881a38aae59ec124a6f7298133"
Expand Down Expand Up @@ -10418,6 +10423,14 @@ limit-spawn@0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/limit-spawn/-/limit-spawn-0.0.3.tgz#cc09c24467a0f0a1ed10a5196dba597cad3f65dc"

line-column@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/line-column/-/line-column-1.0.2.tgz#d25af2936b6f4849172b312e4792d1d987bc34a2"
integrity sha1-0lryk2tvSEkXKzEuR5LR2Ye8NKI=
dependencies:
isarray "^1.0.0"
isobject "^2.0.0"

lines-and-columns@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
Expand Down Expand Up @@ -11437,6 +11450,11 @@ nanoid@2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.3.tgz#dde999e173bc9d7bd2ee2746b89909ade98e075e"

nanoid@^3.1.12:
version "3.1.12"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.12.tgz#6f7736c62e8d39421601e4a0c77623a97ea69654"
integrity sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A==

nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
Expand Down Expand Up @@ -13556,6 +13574,16 @@ postcss@7.0.32, postcss@^7.0.32:
source-map "^0.6.1"
supports-color "^6.1.0"

postcss@8.1.1:
version "8.1.1"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.1.1.tgz#c3a287dd10e4f6c84cb3791052b96a5d859c9389"
integrity sha512-9DGLSsjooH3kSNjTZUOt2eIj2ZTW0VI2PZ/3My+8TC7KIbH2OKwUlISfDsf63EP4aiRUt3XkEWMWvyJHvJelEg==
dependencies:
colorette "^1.2.1"
line-column "^1.0.2"
nanoid "^3.1.12"
source-map "^0.6.1"

postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0.14, postcss@^5.0.16, postcss@^5.0.2, postcss@^5.0.4, postcss@^5.0.5, postcss@^5.0.8, postcss@^5.2.16:
version "5.2.18"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5"
Expand Down

0 comments on commit b89d417

Please sign in to comment.