Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umijs,在禁用cssModule后,如何配置postcss-loader? #8

Open
fallred opened this issue Oct 18, 2018 · 0 comments
Open

umijs,在禁用cssModule后,如何配置postcss-loader? #8

fallred opened this issue Oct 18, 2018 · 0 comments

Comments

@fallred
Copy link

fallred commented Oct 18, 2018

文档https://umijs.org/zh/guide/faq.html#%E5%A6%82%E4%BD%95%E9%85%8D%E7%BD%AE%E9%A2%9D%E5%A4%96%E7%9A%84-loader。文档没有具体的配置postcss部分,我配置.umirc文件后,具体代码如下:
import plugins from './postcss.config';
export default {
plugins: [
[
'umi-plugin-react',
{
dva: true
}
]
],
sass: {},
chainWebpack(config, { webpack }) {
// 设置 alias
//config.resolve.alias.set('a', 'path/to/a');

    // 删除进度条插件
    //config.plugins.delete('progress');

    config.module.rule('css')
    .test(/\.(scss|css|less)$/)
    .use('css-loader')
    .loader('postcss-loader')
},
disableCSSModules: true,
extraPostCSSPlugins: plugins,
cssLoaderOptions: {}

};
postcss.config.js文件代码如下:
const plugins = [
require('postcss-at-rules-variables')(),
require('postcss-import')(),
require('postcss-mixins')(),
require('postcss-bem')({
defaultNamespace: '',
style: 'suit'
})
];

module.exports = plugins;
npm run satrt 启动之后,一直报编译错误:
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant