Webpack 4 - Module parse failed: Unexpected character '@'

前端 未结 2 898
甜味超标
甜味超标 2021-01-17 14:03

I recently upgraded from Webpack 3 to 4. It\'s now throwing an error:

Module parse failed: Unexpected character \'@\' You may need an appropriate lo

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 14:26

    The problem was the script I was using to run Webpack did not specify the config file. This is what it should look like:

    "scripts": {
      "watch": "./node_modules/.bin/webpack --watch --config webpack.dev.js",
    },
    

    I believe this was generating the @import problem because it was not loading the css-loader as without specifying the config file like above, it uses a default Webpack development config which does not include the css-loader.

提交回复
热议问题