Webpack构建错误

Str*_*ch0 4 javascript node.js webpack

与webpack有一些问题.它建立得很好但是当我打开我的网站时,我得到:Getting error: "Uncaught ReferenceError: webpackJsonp is not defined"

我相信我的CommonsChunkPlugin在我的应用程序捆绑之前正在运行?

知道我的配置src/config/webpack.config.js正在建设中可能会有所帮助dist/js/.

已阅读https://medium.com/@MarkEwersDev/note-to-self-if-you-ever-get-this-uncaught-referenceerror-webpackjsonp-is-not-defined-message-and-d354f5c4d335#.9cysuil5phttps://github.com/webpack/webpack/issues/368但似乎没有帮助,除非我遗漏了什么.

  devtool: 'source-map',
  entry: {
    vendor: [
      'react', 'react-dom', 'react-router', 'react-helmet', 'react-redux', 'moment-timezone', 'cookies-js', 'superagent', 'classnames', 'es6-promise'
    ],
    app: [
      './src/client/entry',
      './scss/main.scss',

    ]
  }
  output:{
    path: __dirname + '../../dist/js',
    filename: 'app.js'
  }
  plugins:[
    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),

    new ExtractTextPlugin('../css/app.css', {
        allChunks: true
    }),
    new webpack.DefinePlugin({
      'process.env':{
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: true
      },
      output: {
        comments: false
      }
    }),
    ...persistentPlugins
  ],
Run Code Online (Sandbox Code Playgroud)

Jes*_*hia 12

webpackJsonp函数由公共块定义,因此vendor.js在编写<script>标记时必须始终首先放置公共块(在您的情况下).你也不能使用<script async>.

另一种可能性是,当您设置output.filename为常量字符串时,您的供应商块将被条目块覆盖.尝试命名[name].js而不是app.js.