Skip to content

issue importing dependent sass files #157

Closed

Description

@kgwinnup

I am using webpack to package my app. When running webpack to build the app, the sass files are throwing errors (below).

webpack
/Users/kyle/Documents/workspace/events/client/wip-components/src/css/events.scss:1
(function (exports, require, module, __filename, __dirname) { @import "_bootstrap";
                                                              ^

SyntaxError: Unexpected token ILLEGAL
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:448:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/kyle/Documents/workspace/events/client/wip-components/webpack.config.js:5:1)
    at Module._compile (module.js:430:26)
    at Object.Module._extensions..js (module.js:448:10)

webpack sass config line

{ test: /\.scss$/, loader: 'style!css!sass' },

Activity

  1. jorrit commented on Sep 11, 2015

    @jorrit
    Contributor

    Somehow it is still recognized as javascript. Can you post more config/code?

  2. tomatau commented on Sep 22, 2015

    @tomatau

    Same issue here, same sass config. Running JS through babel stage 0.

    import './sheet.scss';
    and
    require('./sheet.scss');
    
  3. jorrit commented on Sep 24, 2015

    @jorrit
    Contributor

    Can one of you publish a repository that exhibits this problem?

  4. tomatau commented on Sep 25, 2015

    @tomatau

    Fixed here - bug my end with WebpackIsomorphicTools.

  5. typpo commented on Sep 29, 2015

    @typpo

    I am having a similar problem. I'm new to react/webpack/etc, clearly there is something wrong with my config. Having trouble figuring it out.

    (function (exports, require, module, __filename, __dirname) { body {
                                                                             ^
    SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ian/code/react-isomorphic-boilerplate/lib/shared/components/App.js:31:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    

    Here is my webpack config: https://github.com/typpo/react-isomorphic-boilerplate/blob/180daca533120b7065ba2f411eae9104002f1a57/webpack.config.dev.js

    Here is where I'm including the SCSS: https://github.com/typpo/react-isomorphic-boilerplate/blob/180daca533120b7065ba2f411eae9104002f1a57/src/shared/components/App.jsx#L7

    Any thoughts?

  6. typpo commented on Sep 29, 2015

    @typpo

    Nevermind. My problem was that I was trying to run this on both the client and server for my isomorphic app. It should only be on the client so I added an if (typeof window !== 'undefined') around the require in my js file. Also, I made sure to install css-loader and style-loader in dev dependencies.

    Thank you for creating this project!

  7. jhnns commented on Oct 23, 2015

    @jhnns
    Contributor

    @kgwinnup Your webpack.config has a dependency which depends on a scss file.
    @typpo Thanks for pointing that out. Probably a common problem when creating isomorphic/universaljs apps.

  8. ryanm2000 commented on Aug 16, 2016

    @ryanm2000

    @typpo's fix, albeit a bit hacky, does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions