question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

postcss-import issue

See original GitHub issue

Has anyone gotten react-styleguidist working with postcss-import? I’ve gotten the styleguide.config.js matching my app’s webpack config, but I can’t seem to get around this error:

ERROR in ./source/common/style/layout.css
Module parse failed: /home/rstinogle/hv/webclient/app/products/source/common/style/layout.css Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '@' (1:0)

Here is my styleguide.config.js:

var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');
var glob = require('glob');

module.exports = {
  title: 'HireVue Style Guide',
  styleguideDir: '../styleguide/react',
  components: function() {
    return glob.sync(path.resolve(__dirname, 'source/common/components/**/*.jsx')).filter(function(module) {
      return /\/[A-Z]\w*\.jsx$/.test(module);
    });
  },
  updateWebpackConfig: function(webpackConfig) {
    // Your source files folder or array of folders, should not include node_modules
    var dir = path.join(__dirname, 'source/common/components');

    webpackConfig.babelrc = false;
    webpackConfig.module.loaders = webpackConfig.module.loaders.filter(function(obj) {
      return obj.loader !== 'json';
    });
    // webpackConfig.module.loaders = webpackConfig.module.loaders.filter(function(obj) {
    //   return obj.loader.search('css') === -1;
    // });
    webpackConfig.module.loaders.push (
      {
        test: /\.json$/,
        include: /node_modules/,
        loader: 'json-loader'
      },
      {
        test: /\.(es6|jsx)?$/,
        include: dir,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel'
      },
      {
        test: /\.css$/,
        include: dir,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader!css-theme-loader')
      },
      {
        test: /\.(ttf|eot|svg|woff|gif)(\?v=[0-9].[0-9].[0-9])?$/,
        include: /.*/, // Because styleguidist requires either include or exclude.
        loader: 'url?limit=8192'
      }
    );

    webpackConfig.resolveLoader.alias = {
        'css-theme-loader': path.join(__dirname, './source/css-theme-loader')
    };

    webpackConfig.postcss = [
      require('postcss-import'),
      require('postcss-custom-properties'),
      require('autoprefixer')
    ];

    webpackConfig.resolve.extensions.push('.es6');

    var plugins = [
      new ExtractTextPlugin('[name].css'),
    ];

    webpackConfig.plugins = webpackConfig.plugins.concat(plugins);

    console.log(webpackConfig);
    return webpackConfig;
  }
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
stinogacommented, Nov 10, 2016

Closing this. I figured out the problem by editing the example repo.

0reactions
deanbrophycommented, Jun 4, 2018

Just a note: I ran into this issue after ejecting create-react-app. The fix was adding a webpackConfig attribute to my styleguide.config.js.

module.exports = {
  webpackConfig: require("./config/webpack.config.dev.js"),
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · postcss/postcss-import - GitHub
PostCSS plugin to inline @import rules content. Contribute to postcss/postcss-import development by creating an account on GitHub.
Read more >
postcss-import - npm
PostCSS plugin to import CSS files. Latest version: 15.1.0, last published: 18 days ago. Start using postcss-import in your project by ...
Read more >
postcss-import | Yarn - Package Manager
PostCSS plugin to transform @import rules by inlining content. This plugin can consume local files, node modules or web_modules. To resolve path of...
Read more >
postcss-import examples - CodeSandbox
Postcss Import Examples. Learn how to use postcss-import by viewing and forking example apps that make use of postcss-import on CodeSandbox.
Read more >
Newest 'postcss-import' Questions - Stack Overflow
I've been using Laravel Mix with nested Tailwindcss for a while with no issues. Now I've got a new Laravel 9 build and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found