After installing style-loader and css-loader, when introducing the css file into the component, it reports that the module cannot be found. The configuration file of webpack is as follows:
context: __dirname '/src',
entry:"./js/index.js",
module:{
loaders:[{
test:/\.js?$/,
exclude:/(node_modules)/,
loader: "babel-loader",
query:{
presets:['react','es2015'],
plugins:['react-html-attrs'],
}
},
{
//test:/\.css$/,
//loader:'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]'
test: /\.css$/,
loader: 'style-loader!css-loader'
}]
},
output:{
path:__dirname+"/src/",
filename:"bundle.js"
}
Introduce the css file as follows:
var footerCss = require("../../css/style.css");
export default class ComponentFooter extends React.Component{
render(){
console.log(footerCss);
The error message is as follows:
Uncaught Error: Cannot find module "../../css/style.css"
at webpackMissingModule (bundle.js:9979)
at Object.defineProperty.value (bundle.js:9979)
at __webpack_require__ (bundle.js:20)
at Object.ARIADOMPropertyConfig.Properties.aria-current (bundle.js:10178)
at __webpack_require__ (bundle.js:20)
at module.exports (bundle.js:66)
at bundle.js:69
Note: There is a footer.css file under src/css
The css file is not a Module, unlike other components that have export...
How to use:
or: