加载了所有-loader还是无法打包

来源:4-6 处理模板文件

MonKey_526

2017-08-19 03:51

明明所有loader都下载到局部环境了:

  "devDependencies": {

    "autoprefixer": "^7.1.2",

    "babel-core": "^6.26.0",

    "babel-loader": "^7.1.1",

    "babel-preset-latest": "^6.24.1",

    "css-loader": "^0.28.5",

    "html-loader": "^0.5.1",

    "html-webpack-plugin": "^2.30.1",

    "less-loader": "^4.0.5",

    "node-sass": "^4.5.3",

    "postcss-loader": "^2.0.6",

    "style-loader": "^0.18.2",

    "webpack": "^3.5.5"

打包时还是疯狂报错:

ERROR in ./src/components/layer/layer.less

Module parse failed: C:\Users\Haopc\Desktop\webpack-demo-sourceFile\src\components\layer\layer.less Unexpected token (2:0)

You may need an appropriate loader to handle this file type.


ERROR in ./src/css/common.css

Module parse failed: C:\Users\Haopc\Desktop\webpack-demo-sourceFile\src\css\common.css Unexpected character '@' (1:0)

You may need an appropriate loader to handle this file type.


本来是html报错,我把webpack.config.js删了重新写了一个,就变成这样了,弄到现在凌晨4点心态崩了。有老哥帮帮我吗?

写回答 关注

3回答

  • Tanjia
    2018-10-24 10:53:55

    需要装一个less  ,npm 命令安装:npm install less --save-dev ,安装完成之后在安装less-loader,命令:npm install less-loader --save-dev

  • 长城不倒
    2017-08-24 15:02:50

    webpack.config.js俩面有这个吗:

    {

        test: /\.less$/,

        use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'] 

    },


  • 慕婉清2333136
    2017-08-20 17:48:20

    报错信息上不是有吗?你的less文件打包失败了,应该是你的less没装吧,装一下less应该就就好了

    慕斯卡754... 回复MonKey...

    这个问题你解决了吗

    2018-03-08 15:38:40

    共 2 条回复 >

webpack深入与实战

webpack实战教程,用真实项目带你探索 webpack 强大的功能

86561 学习 · 721 问题

查看课程

相似问题