preact 的节点 SASS

Node SASS for preact

我用 preact-clidefault 模板开始了一个项目。我安装了 node-sasssass-loader。我将其中一个 .css 文件更改为 .scss 然后整个事情就崩溃了并给出了这个错误。

✖ ERROR BabelEsmPlugin: ./routes/profile/style.scss (../node_modules/preact-cli/lib/lib/webpack/proxy-loader.js??ref--6-0!./routes/profile/style.scss)
Module build failed (from ../node_modules/preact-cli/lib/lib/webpack/proxy-loader.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
 - options has an unknown property 'includePaths'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (./routes/profile/index.js
 @ ./routes/profile/index.js
 @ ./components/app.js
 @ ./index.js
 @ ../node_modules/preact-cli/lib/lib/entry.js
 @ multi ../node_modules/webpack-dev-server/client?http://0.0.0.0:8080 ../node_modules/webpack/hot/dev-server.js ../node_modules/preact-cli/lib/lib/entry webpack-dev-server/client webpack/hot/dev-server

此错误是针对 sass-loader 版本 8 你应该使用

yarn add -D sass-loader@7.3.1

(或使用 npm)

npm add --save-dev sass-loader@7.3.1

来自 https://github.com/preactjs/preact-cli/issues/880

如果您使用 sass 加载程序选项,也许这个快速修复可能会有所帮助(等待合并)https://github.com/preactjs/preact-cli/pull/930

希望对您有所帮助。

您还可以查看官方文档以使用 preact-cli
创建项目 Link for docs