Home > front end >  Teach: webpack introduced CSS styles to quote This relative module was not found
Teach: webpack introduced CSS styles to quote This relative module was not found

Time:11-27

First, create a vue initialization webpack empty project, namely:
 vue init webpack vuelessproject 

Second, the local installation CSS - loader and style - loader package:
 CNPM install - save - dev CSS - loader style - loader 

Then, in the build/webpack. Base. Conf., js, add the following code:
 
The module: {
Rules: [
{
Test:/\. CSS $/,
Use: [{
Loader: "style - loader"
}, {
Loader: "CSS - loader,"
Options: {
Modules: true
}
}]
},

At the same time, under the SRC directory to create a style. The CSS file:
 
. Hello {
color: red;
}

Finally, in the main, js, add the following code:
 import './style. CSS '

The terminal operation NPM run dev to start the project and submit them to the following error:
 
The ERROR Failed to compile with 1 errors 21:24:30

This relative module was not found:

*./style. The CSS in the./SRC/main js

CodePudding user response:

Is very simple, into the wrong path, your main. Js and your CSS files, should not in a folder, where are you going to introduce CSS folder path, '/' the meaning of the meaning is the same folder

CodePudding user response:

Actual situation I really put the two files are in the same directory below
  • Related