React Styleguidist 和 SASS

mik*_*kek 2 sass reactjs react-styleguidist

所以我的设置很简单

样式指南.config.js

module.exports = {
    components: 'src/components/**/*.js',
    require: [
        path.join(__dirname, 'node_modules/bootstrap/scss/bootstrap.scss')
    ]
};
Run Code Online (Sandbox Code Playgroud)

每当我运行 npm run styleguide 时,我都会收到此错误:

模块解析失败:意外字符@您可能需要合适的加载程序来处理此文件类型。

bootstrap.scss看起来像这样:

@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/mixins";
...
...
Run Code Online (Sandbox Code Playgroud)

我知道我需要添加 SASS-loader,但我发现的示例使用不同的上下文,所以我还不能真正弄清楚它们。

ps 当我运行应用程序本身时,SASS 在 React Styleguide 之外工作,而不是 styleguide。

mik*_*kek 5

好的,解决方案是确保您的主要项目可以编译 SASS。但那是一个不同的问题。

我只需要将 webpackConfig 添加到

样式指南.config.js

module.exports = {
    components: 'src/kitchensink/**/*.js',
    webpackConfig: require('./config/webpack.config.dev.js'),
    require: [
        path.join(__dirname, './src/sass/bootstrap.scss')
    ]
};
Run Code Online (Sandbox Code Playgroud)