样式
module.exports = {
// ...
style: {
modules: {
localIdentName: '',
},
css: {
loaderOptions: { /* ... */ },
loaderOptions: (cssLoaderOptions, { env, paths }) => {
/* ... */
return cssLoaderOptions;
},
},
sass: {
loaderOptions: { /* ... */ },
loaderOptions: (sassLoaderOptions, { env, paths }) => {
/* ... */
return sassLoaderOptions;
},
},
postcss: {
mode: 'extends' /* (default value) */ || 'file',
plugins: [require('plugin-to-append')],
plugins: (plugins) => [require('plugin-to-prepend')].concat(plugins),
env: {
autoprefixer: { /* ... */ },
stage: 3,
features: { /* ... */ },
},
loaderOptions: { /* ... */ },
loaderOptions: (postcssLoaderOptions, { env, paths }) => {
/* ... */
return postcssLoaderOptions;
},
},
},
};
对于上面大纲中列出两次的属性(如 loaderOptions
),可以指派对象字面量或函数。详情请见 配置提示。
style.modules
style.modules.localIdentName
字符串
https://github.com/webpack-contrib/css-loader#localidentname
style.css
style.css.loaderOptions
CSSLoaderOptions
或 (options: CSSLoaderOptions, { env, paths }) => CSSLoaderOptions
任何 CSS 加载器配置选项:https://github.com/webpack-contrib/css-loader#options
style.sass
style.sass.loaderOptions
SASSLoaderOptions
或 (options: SASSLoaderOptions, { env, paths }) => SASSLoaderOptions
任何 SASS 加载器配置选项:https://github.com/webpack-contrib/sass-loader#options
style.postcss
style.postcss.mode
'extends' | 'file' = 'extends'
请参阅 覆盖模式。
style.postcss.plugins
[PostCSSPlugin]
或 (plugins: [PostCSSPlugin]) => [PostCSSPlugin]
任何 PostCSS 插件:https://github.com/postcss/postcss#plugins
style.postcss.env
style.postcss.env.autoprefixer
AutoprefixerOptions
任何 autoprefixer 选项:https://github.com/postcss/autoprefixer#options
style.postcss.env.stage
0 | 1 | 2 | 3 | 4
任何有效的 CSS 阶段:https://cssdb.org/#the-staging-process
style.postcss.env.features
任何 CSS 功能:https://preset-env.cssdb.org/features/
style.postcss.loaderOptions
PostCSSLoaderOptions
或 (options: PostCSSLoaderOptions, { env, paths }) => PostCSSLoaderOptions
任何 postcss-loader 选项:https://github.com/webpack-contrib/postcss-loader#options