I use the current version of react-boilerplate (which uses webpack) and installed Semantic-UI-React like described in the official docs http://react.semantic-ui.com/usage
When I start the server I get:
Server started ! ✓
Access URLs:
-----------------------------------
Localhost: http://localhost:3000
LAN: http://192.168.100.103:3000
-----------------------------------
Press CTRL-C to stop
webpack built dba595efb772df0727e8 in 11657ms
ERROR in ./semantic/dist/semantic.min.css
Module parse failed: /Users/standardnerd/development/template/semantic/dist/semantic.min.css Unexpected character '@' (11:0)
You may need an appropriate loader to handle this file type.
| *
| */
| @import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin);/*!
| * # Semantic UI 2.2.7 - Reset
| * http://github.com/semantic-org/semantic-ui/
@ ./app/app.js 20:0-43
@ multi main
What kind of 'appropriate loader' do I need?
The parser doesn't like the @import statement in /semantic/dist/semantic.min.css:
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin);
How to resolve this issue?
If you're using an include directive in the rule make sure to include also node_modules:
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'resolve-url-loader'],
include: [
path.join(__dirname, 'src'),
/node_modules/
],
},
That should fix the problem as it you're instructing webpack to make sure to include node modules when loading css so that it can properly utilize the css-loader when importing the semantic ui css package.
Step1: Install following packages
npm install --save-dev css-loader sass-loader node-sass url-loader file-loader
Step2: Then, in webpack.config.js file:
module: {
rules: [
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.s[a|c]ss$/,
loader: 'sass-loader!style-loader!css-loader'
},
{
test: /\.(jpg|png|gif|jpeg|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
}
]
}
Step3: In modules,
If you installed semantic css via npm package npm install --save-dev semantic-ui-css
, then import entry should be import './node_modules/semantic-ui-css/semantic.min.css'
Use relavent import statment if you have not installed semantic-ui-css
via npm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With