установить sass-загрузчик при ошибке config webpack4.0 - PullRequest
1 голос
/ 16 мая 2019

Устанавливаю sass-loader при настройке webpack4.0. Введите файл шрифта.

Произошла странная ошибка. Я предполагаю, что может быть конфликт.

ошибка: неожиданный символ '@' (1: 0) Вам может понадобиться соответствующий загрузчик для обработки этого типа файлов.

Я пытался ее решить, но ничего не мог поделать, помогите мне.

package.json

 "devDependencies": {
  ...
    "css-loader": "^2.1.1",
    "dart-sass": "^1.20.1",
    "file-loader": "^3.0.1",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
  ...
  }

webpack.config.js

  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
        ...
          {
            loader: 'sass-loader',
            options: {
              implementation: require('dart-sass')
            }
          },
          {
            loader: 'postcss-loader'
          }
        ]
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf)$/,
        use: ['file-loader']
      },
      ...
    ]
  }

* 1015 СКС *

@font-face {
  font-family: 'MyFont';
  src: url('./PingFang.ttf') format('ttf');
  font-weight: 600;
  font-style: normal;
}

Я надеюсь запустить sass правильно.

но

ошибка

app.46c6d5794b0000048c06.js:56 Uncaught Error: Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
> @font-face {
|   font-family: 'MyFont';
|   src: url('./PingFang.ttf') format('ttf');
    at Object.lE3a (app.46c6d5794b0000048c06.js:56)
    at __webpack_require__ (bootstrap:78)
    at Module.<anonymous> (index.js:1)
    at Module.tjUo (app.46c6d5794b0000048c06.js:81)
    at __webpack_require__ (bootstrap:78)
    at Object.0 (app.46c6d5794b0000048c06.js:11)
    at __webpack_require__ (bootstrap:78)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at app.46c6d5794b0000048c06.js:1
lE3a @ app.46c6d5794b0000048c06.js:56
__webpack_require__ @ bootstrap:78
(anonymous) @ index.js:1
tjUo @ app.46c6d5794b0000048c06.js:81
__webpack_require__ @ bootstrap:78
0 @ app.46c6d5794b0000048c06.js:11
__webpack_require__ @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ app.46c6d5794b0000048c06.js:1
client:200 [WDS] Errors while compiling. Reload prevented.
errors @ client:200
onmessage @ socket.js:40
EventTarget.dispatchEvent @ sockjs.js:170
(anonymous) @ sockjs.js:887
SockJS._transportMessage @ sockjs.js:885
EventEmitter.emit @ sockjs.js:86
WebSocketTransport.ws.onmessage @ sockjs.js:2961
client:209 ./src/style.scss 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
> @font-face {
|   font-family: 'MyFont';
|   src: url('./PingFang.ttf') format('ttf');

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...