我正在创建一个使用node-sass-middleware
呈现scss文件的Web应用程序。我的问题是呈现位于node_modules
(material-components-web
或normalize.css
)
app.use(require('node-sass-middleware')({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public'),
indentedSyntax: false
}));
css + scss文件位于/ public / css /
中<head>
<link rel="stylesheet" href="/css/css-file.css">
<link rel="stylesheet" href="/css/scss-file.css" />
<link rel="stylesheet" href="/node_modules/normalize.css/normalize.css" />
<link rel="stylesheet" href="/node_modules/material-components-web/material-components-web.css" />
<link rel="stylesheet" href="/node_modules/material-components-web/dist/material-components-web.css" />
</head>
|-- public
| |-- css
| |-- css-file.css
| |-- scss-file.scss
|-- node-modules
| |-- material-components-web
| | |-- dist
| | |-- material-components.css
| | |-- material-components.scss
| |
| |-- normalize.css
|-- normalize.css
source: [path-to-app]\public\css\css-file.scss
dest: [path-to-app]\public\css\css-file.css
read: [path-to-app]\public\css\css-file.css
source: [path-to-app]\public\node_modules\normalize.css\normalize.scss
dest: [path-to-app]\public\node_modules\normalize.css\normalize.css
read: [path-to-app]\public\node_modules\normalize.css\normalize.css
source: [path-to-app]\public\node_modules\material-components-web\material-components-web.scss
dest: [path-to-app]\public\node_modules\material-components-web\material-components-web.css
read: [path-to-app]\public\node_modules\material-components-web\material-components-web.css
source: [path-to-app]\public\node_modules\material-components-web\dist\material-components-web.scss
dest: [path-to-app]\node_modules\material-components-web\dist\material-components-web.css
read: [path-to-app]\node_modules\material-components-web\dist\material-components-web.css
source: [path-to-app]\public\css\scss-file.scss
dest: [path-to-app]\public\css\scss-file.css
read: [path-to-app]\public\css\scss-file.css
render: [path-to-app]\public\css\scss-file.scss
GET /node_modules/material-components-web/material-components-web.css 304 7.978 ms - -
GET /css/css-file.css 200 16.435 ms - -
GET /css/scss-file.css 200 17.562 ms - -
GET /node_modules/normalize.css/normalize.css 404 24.691 ms - 5378
GET /node_modules/material-components-web/dist/material-components-web.css 404 28.336 ms - 5378
我尝试了不同的设置,例如public / css中的includePath + scss文件,它们导入位于node_modules中的css文件。没有任何帮助:/