postcss-import issue
See original GitHub issueHas 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:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing this. I figured out the problem by editing the example repo.
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
.