Just touching the webpack, in a demo, the document structure is as follows:
Css is introduced into index.js, i.e. require(‘./main.css’); But when I remove …/,I report the mistake. According to my idea, require(‘main.css’); Don’t you also find main.css based on index.js?
I hope you can help and guide me.
This is a commonJS-style dependency statement used by Node
require()The characteristics of the decision.
require(X)Statement, follow the following principles:
If x is equal to
../At the beginning, it is considered as a relative path, and it is found according to the position of the title owner relative to the current file.
If it is not the beginning of the above, it is considered as a built-in module (e.g.
require('path')), or at
node_modulesNpm package in inside (e.g.
Implemented by webpack
require()This query principle is also followed. The topic owner can read Mr. Ruan’sThis article