Error: Can't resolve 'fs' in (webpack 2配置CSS loadeers)

前言,在之前有配置过webpack 2 中css loaders,但是怎么也不正确

报错:

ERROR in ./~/convert-source-map/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/ceshi/Desktop/webpack/node_modules/convert-source-map'
 @ ./~/convert-source-map/index.js 2:9-22
 @ ./~/css-loader/lib/css-base.js
 @ ./~/css-loader!./app/style.css
 @ ./app/style.css
 @ ./app/main.js

Error: Can't resolve 'fs' in (webpack 2配置CSS loadeers)_第1张图片

解决方法,修改webpack的配置文件,增加一句代码

 node: {
        fs: 'empty'
    },

Error: Can't resolve 'fs' in (webpack 2配置CSS loadeers)_第2张图片

测试成功

你可能感兴趣的:(前端)