位于node_modules

时间:2017-02-18 23:46:36

标签: node.js node-sass

我正在创建一个使用node-sass-middleware呈现scss文件的Web应用程序。我的问题是呈现位于node_modulesmaterial-components-webnormalize.css

的css文件

应用程序/ server.js

app.use(require('node-sass-middleware')({
    src: path.join(__dirname, 'public'),
    dest: path.join(__dirname, 'public'),
    indentedSyntax: false
}));

css + scss文件位于/ public / css /

模板/ HTML

<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文件。没有任何帮助:/

0 个答案:

没有答案