Skip to content

Commit

Permalink
feat(types): add postcss build types (#223)
Browse files Browse the repository at this point in the history
* feat(types): add postcss build types

* style(types): alphabetise

* fix: remove extraneous comma

Co-Authored-By: Kevin Marrec <kevin@marrec.io>
  • Loading branch information
danielroe and kevinmarrec committed Dec 1, 2019
1 parent 2631980 commit 7268990
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
55 changes: 45 additions & 10 deletions packages/types/config/build.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
* Documentation: https://nuxtjs.org/api/configuration-build
*/

import { TransformOptions, PluginItem } from '@babel/core'
import { Options as AutoprefixerOptions } from 'autoprefixer'
import { Options as FileLoaderOptions } from 'file-loader'
import { Options as HtmlMinifierOptions } from 'html-minifier'
import * as Less from 'less'
import { Options as SassOptions } from 'node-sass'
import { Options as OptimizeCssAssetsWebpackPluginOptions } from 'optimize-css-assets-webpack-plugin'
import { Plugin as PostcssPlugin } from 'postcss'
import { Options as PugOptions } from 'pug'
import { TerserPluginOptions } from 'terser-webpack-plugin'
import { VueLoaderOptions } from 'vue-loader'
import {
Configuration as WebpackConfiguration,
Loader as WebpackLoader,
Options as WebpackOptions,
Plugin as WebpackPlugin
} from 'webpack'
import { TransformOptions, PluginItem } from '@babel/core'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import { Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware'
import { Options as WebpackHotMiddlewareOptions } from 'webpack-hot-middleware'
import { Options as HtmlMinifierOptions } from 'html-minifier'
import { Options as OptimizeCssAssetsWebpackPluginOptions } from 'optimize-css-assets-webpack-plugin'
import { TerserPluginOptions } from 'terser-webpack-plugin'
import { Options as FileLoaderOptions } from 'file-loader'
import { Options as PugOptions } from 'pug'
import * as Less from 'less'
import { Options as SassOptions } from 'node-sass'
import { VueLoaderOptions } from 'vue-loader'

type CssLoaderUrlFunction = (url: string, resourcePath: string) => boolean
type CssLoaderImportFunction = (parsedImport: string, resourcePath: string) => boolean
Expand Down Expand Up @@ -95,6 +97,39 @@ interface Warning {
name: string
}

interface PostcssOrderPresetFunctions {
cssnanoLast: (names: string[]) => string[]
presetEnvAndCssnanoLast: (names: string[]) => string[]
presetEnvLast: (names: string[]) => string[]
}
type PostcssOrderPreset = keyof PostcssOrderPresetFunctions
interface PostcssVariableMap {
customMedia: Record<string, string>
customProperties: Record<string, string>
customSelectors: Record<string, string>
environmentVariables?: Record<string, string>
}

interface PostcssConfiguration {
order?: PostcssOrderPreset | string[] | ((names: string[], presets: PostcssOrderPresetFunctions) => string[])
plugins?: {
[key: string]: false | { [key: string]: any }
}
preset?: {
autoprefixer?: false | AutoprefixerOptions
browsers?: string
exportTo?: string | string[] | Partial<PostcssVariableMap> | ((map: PostcssVariableMap) => Partial<PostcssVariableMap>)
features?: {
[key: string]: boolean | { [key: string]: any }
}
importFrom?: string | string[] | Partial<PostcssVariableMap> | (() => Partial<PostcssVariableMap>)
insertAfter?: { [key: string]: PostcssPlugin<any> }
insertBefore?: { [key: string]: PostcssPlugin<any> }
preserve?: boolean
stage?: 0 | 1 | 2 | 3 | 4 | false
}
}

export interface NuxtConfigurationBuild {
additionalExtensions?: string[]
analyze?: BundleAnalyzerPlugin.Options | boolean
Expand Down Expand Up @@ -122,7 +157,7 @@ export interface NuxtConfigurationBuild {
optimizeCSS?: OptimizeCssAssetsWebpackPluginOptions | boolean
parallel?: boolean
plugins?: WebpackPlugin[]
postcss?: any // TBD
postcss?: string[] | boolean | PostcssConfiguration | (() => PostcssConfiguration)
profile?: boolean
publicPath?: string
quiet?: boolean
Expand Down
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"types": "index",
"dependencies": {
"@types/autoprefixer": "^9.6.1",
"@types/babel__core": "^7.1.3",
"@types/compression": "^1.0.1",
"@types/connect": "^3.4.32",
Expand Down
15 changes: 14 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,14 @@
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==

"@types/autoprefixer@^9.6.1":
version "9.6.1"
resolved "https://registry.yarnpkg.com/@types/autoprefixer/-/autoprefixer-9.6.1.tgz#8bfaf43d18f5cd59a269b7a2364e690cadcdf210"
integrity sha512-9aofAxm/OWxzu/Fq7lU/m2rX03f9Sr1OXF/3kEp6FNFYRFLgFcIUjxhNGgWqc5KMpXbkqxlJmc7wfab7jFj2dw==
dependencies:
"@types/browserslist" "*"
postcss "7.x.x"

"@types/babel__core@^7.1.0", "@types/babel__core@^7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30"
Expand Down Expand Up @@ -2143,6 +2151,11 @@
"@types/connect" "*"
"@types/node" "*"

"@types/browserslist@*":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@types/browserslist/-/browserslist-4.4.0.tgz#e2a5f7f8c7e97afb39f50812a77e5230d3ca2353"
integrity sha512-hrIjWSu7Hh96/rKlpChe58qHEwIZ0+F5Zf4QNdvSVP5LUXbaJM04g9tBjo702VTNqPZr5znEJeqNR3nAV3vJPg==

"@types/clean-css@*":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@types/clean-css/-/clean-css-4.2.1.tgz#cb0134241ec5e6ede1b5344bc829668fd9871a8d"
Expand Down Expand Up @@ -9728,7 +9741,7 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1:
indexes-of "^1.0.1"
uniq "^1.0.1"

postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.23, postcss@^7.0.5, postcss@^7.0.6:
postcss@7.x.x, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.23, postcss@^7.0.5, postcss@^7.0.6:
version "7.0.23"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.23.tgz#9f9759fad661b15964f3cfc3140f66f1e05eadc1"
integrity sha512-hOlMf3ouRIFXD+j2VJecwssTwbvsPGJVMzupptg+85WA+i7MwyrydmQAgY3R+m0Bc0exunhbJmijy8u8+vufuQ==
Expand Down

0 comments on commit 7268990

Please sign in to comment.