PostCSS Normalize includes a postcssImport function to configure
PostCSS Import and allow you to continue using the @import syntax.
const postcss = require('postcss')const postcssImport = require('postcss-import')const postcssNormalize = require('postcss-normalize')postcss([ postcssImport( postcssNormalize( /* pluginOptions (for PostCSS Normalize) */ ).postcssImport( /* pluginOptions (for PostCSS Import) */ ) )]) // now you can use @import "normalize.css", etc. again
Alternatively, use @import-normalize or @import-sanitize to avoid conflicts
with @import transforms.
@import-normalize;
@import-normalize "normalize/opinionated.css";
@import-sanitize;
Options
allowDuplicates
The allowDuplicates option determines whether multiple, duplicate insertions
of CSS libraries are allowed. By default, duplicate libraries are omitted.
postcssNormalize({ allowDuplicates: true })
forceImport
The forceImport option defines CSS libraries that will be inserted at the
beginning of the CSS file. Unless overriden by allowDuplicates, duplicate
CSS libraries would still be omitted.
postcssNormalize({ forceImport: true })
Specific CSS libraries may be defined.
postcssNormalize({ forceImport: 'sanitize.css'})
browsers
The browsers option defines an override of the project’s browserslist for
PostCSS Normalize. This option should be avoided in leui of a browserslist
file.
postcssNormalize({ browsers: 'last 2 versions' })
CSS Libraries
PostCSS Normalize can include normalize.css or sanitize.css and
configure either with the following combinations: