I am using React with Webpack 4. I am trying to import the BassCSS classes in my index.css
:
@import "basscss"
@import "basscss-colors"
@import "basscss-background-colors"
However, it seems like the imports are not applied. Webpack does not throw any error messages or warnings.
For example, the BassCSS class red
does not make my header text red:
import React from 'react'
const Header = () => (
<header className="red">
<h1>My App</h1>
</header>
)
export default Header
The index.css
is imported in my index.js:
import './styles/index.css'
It will make my header text red if I comment out my imports and manually define the red
class like so:
/* @import "basscss"
@import "basscss-colors"
@import "basscss-background-colors" */
.red {
color: red;
}
Using webpack
, I have configured the style-loader
, the css-loader
and the postcss-loader
for CSS files:
...
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
}
...
This is how my postcss.config.js
looks like:
const postcssCssNext = require('postcss-cssnext')
const postcssImport = require('postcss-import')
module.exports = {
plugins: [
postcssCssNext,
postcssImport
]
}
And lastly, my dependencies from my package.json
:
...
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-cli": "^6.26.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.0.0",
"dotenv": "^8.0.0",
"file-loader": "^4.0.0",
"html-webpack-plugin": "^3.2.0",
"postcss": "^7.0.17",
"postcss-cssnext": "^3.1.0",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"style-loader": "^0.23.1",
"webpack": "^4.34.0",
"webpack-cli": "^3.3.4",
"webpack-dev-server": "^3.7.1"
},
"dependencies": {
"basscss": "^8.1.0",
"basscss-background-colors": "^2.1.0",
"basscss-colors": "^2.2.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"whatwg-fetch": "^3.0.0"
}
...
change
@import "basscss"
@import "basscss-colors"
@import "basscss-background-colors"
into
@import "basscss";
@import "basscss-colors";
@import "basscss-background-colors";
css requires each rule to end with ;
but it's optional of the last line