How to use absolute path to import custom scss, when using react + webpack?

后端 未结 4 1432
北恋
北恋 2021-02-05 04:47

Inside a scss file, I\'m trying to import custom, widely used chunk of scss (in a React/SASS/Webpack stack).

So that I can use a shared mixin.

Let\'s say I\'m cr

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 05:30

    I had to do so more research to solve this issue using other answers so here is my working solution:

    // Webpack config
    {
      test: /\.scss$/,
      loader: 'sass-loader',
      options: {
        includePaths: [path.resolve(__dirname, '')],
      },
    },
    

    Then in your scss file:

    @import 'filename.scss'; // Imported from  folder.
    
    .style {
      //...
    }
    

提交回复
热议问题