最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】Webpack加了url-loader和file-loader以及extensions后打包出错:configuration.resolve.extensions[0] should not be empty

Webpack crifan 727浏览 0评论

折腾:

【已解决】Webpack打包出错:ERROR in Entry module not found Cannot resolve file or directory

期间,改为:

    // extensions: [‘.jsx’, ‘.js’, ‘.json’, ‘.less’]
    extensions: [”, ‘.jsx’, ‘.js’, ‘.json’, ‘.less’]

结果:

➜  react-hot-boilerplate git:(master) ✗ webpack –progress –colors –display-error-details
process.env.NODE_ENV=undefined, isProd=false
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
– configuration.resolve.extensions[0] should not be empty.

参考之前的:

【已解决】ant-design-mobile配置webpack出错:configuration.resolve.extensions[0] should not be empty

改为:

    extensions: [‘*’, ‘.jsx’, ‘.js’, ‘.json’, ‘.less’]
    // extensions: [‘.jsx’, ‘.js’, ‘.json’, ‘.less’]
    // extensions: [”, ‘.jsx’, ‘.js’, ‘.json’, ‘.less’]

结果:问题同上。

感觉挺奇怪的:

好像是:

此处加上了自动查找后缀,结果index.js会被自动去尝试index.js.js,结果找不到了。

难道是加上了extensions后,其他写法就一定不能加上后缀?

但是看到别处也是可以有extensions也有后缀写法的啊:

  entry: [‘babel-polyfill’, ‘./index.js’],
  output: {
    path: path.resolve(__dirname, “build”),
    // publicPath: ‘/’,
    publicPath: ‘/uapp/’,
    // publicPath: ‘./uapp/’,
    // filename: ‘bundle.js’
    filename: ‘bundle_[hash].js’
  },
  resolve: {
    extensions: [‘.jsx’, ‘.js’, ‘.json’, ‘.less’],

难道是webpack 3.x中语法不一样了?

去找官网文档:

Resolve

结果没变啊。

看到官网的注释:

Using this will override the default array, meaning that webpack will no longer try to resolve modules using the default extensions. For modules that are imported with their extension, e.g. import SomeFile from “./somefile.ext”, to be properly resolved, a string containing “*” must be included in the array.

感觉是:

暂时不用这个extensions? 或许就可以了?

webpack extensions configuration.resolve.extensions 0 should not be empty

The examples are not working ? · Issue #52 · alex3165/react-mapbox-gl

【总结】

结果的结果:

extensions: [‘*’, ‘.jsx’, ‘.js’, ‘.json’, ‘.less’]

是可以的了。

-》说明刚才也是这么写,但是不能工作,则很明显是:

总之导致了,虽然文件更改并了,但是文件内容却没有用到最新的

可能是:

Webpack的bug?

此处终端iTerm的bug?

总之不管了。希望以后不要出现这里无语的bug。

【后记】

后来确认,貌似是iTerm的bug(因为又遇到了之前的fsevent之类的错误了),重启iTerm后,估计后面就不会出现这个问题了。

转载请注明:在路上 » 【已解决】Webpack加了url-loader和file-loader以及extensions后打包出错:configuration.resolve.extensions[0] should not be empty

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
65 queries in 0.124 seconds, using 18.89MB memory