Giter Site home page Giter Site logo

Comments (8)

coryhouse avatar coryhouse commented on May 6, 2024 1

@superkat64 - That's already configured in master. https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.prod.js#L129

from react-slingshot.

superkat64 avatar superkat64 commented on May 6, 2024 1

@coryhouse Thank you so much! I must have removed it trying to figure it all out on accident or I'm just blind. Really appreciate the quick response

Edit: I was looking at the wrong config file the whole time 😓

from react-slingshot.

coryhouse avatar coryhouse commented on May 6, 2024

Does it work fine with npm start?

I ask because that behavior hasn't changed.

Only npm run build uses the ExtractTextPlugin to generate a separate CSS file.

from react-slingshot.

harrisrobin avatar harrisrobin commented on May 6, 2024

hey @coryhouse yes it does. I believe there might be a problem with the way im doing it (sorry, im new to webpack). In contrast, here is a version that works in my other projects using webpack:

{ test: /\.scss$/, loader: "style!css!sass?includePaths[]=" + bourbon},
But im not sure how to do it with ExtractTextPlugin. I'll try a few things later this week and report back, so far I have simply included bourbon in the styles folder and important it manually, but would be way better to have it globally and simply use @import 'bourbon'

from react-slingshot.

coryhouse avatar coryhouse commented on May 6, 2024

Yesterday I coincidentally hit the same wall. On a separate project I'm trying to get @import to work within a CSS file that I'm loading via Webpack. Let me know if/when you have any luck, and I'll do the same.

from react-slingshot.

darcnite3000 avatar darcnite3000 commented on May 6, 2024

I did some googling on the web and found

const sassPaths = bourbon
  .includePaths
  .map((sassPath)=>`includePaths[]=${sassPath}`)
  .join('&');

and

const sassPaths = bourbon
  .with([
    path.resolve(__dirname,'./src/styles')
  ])
  .map((sassPath)=>`includePaths[]=${sassPath}`)
  .join('&');

this type of code. which on my testing seemed to work.

thus the loaders were

if(env === productionEnvironment){
    loaders.push({
      test: /(\.css|\.scss)$/,
      include: path.join(__dirname, 'src'),
      loader: ExtractTextPlugin.extract(`css?sourceMap!postcss!sass?sourceMap&${sassPaths}`)
    });
  }else{
    loaders.push({
      test: /(\.css|\.scss)$/,
      include: path.join(__dirname, 'src'),
      loaders: ['style', 'css?sourceMap', 'postcss', `sass?sourceMap&${sassPaths}`]
    });
  }

from react-slingshot.

harrisrobin avatar harrisrobin commented on May 6, 2024

@darcnite3000 that solution worked for me. Thanks!

from react-slingshot.

superkat64 avatar superkat64 commented on May 6, 2024

Hey hey!
Do we happen to have the solution for configuring webpack to use MiniCssExtractPlugin now that Webpack 4 doesn't use ExtractTextPlugin anymore. I've been tinkering with my app and also have been receiving the same File to import not found or unreadable: stylesheets/variables error.

Currently, this is the only change I've made:

plugins: [
    // .. the other plugins
    new MiniCssExtractPlugin()
  ],
  module: {
    rules: [
      {
        test: /(\.css|\.scss|\.sass)$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader
          },
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'postcss-loader',
            options: {
              plugins: () => [require('autoprefixer')],
              sourceMap: true
            }
          },
          {
            loader: 'sass-loader',
            options: {
              includePaths: [path.resolve(__dirname, 'src', 'scss')],
              sourceMap: true
            }
          }
        ]
      },

I appreciate any help, webpack is still foreign territory for me but I'm trying to get more familiar with it. Will keep googling in the meantime

from react-slingshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.