javascript - webpack设置chunks后提示 webpackJsonp is not defined,如何解决?
天蓬老师
天蓬老师 2017-04-11 10:34:17
0
1
366

1.由于是两个页面就设置了两个入口,那么现在就有一个问题,就是打包的时候两个页面引入的所有js文件都会打包进去。
2.为了解决这个问题,看了下网上的说明可以使用chunks指定引入的打包文件,结果指定以后报错了。


webpack.config.js

entry:{
      index: './src/index.ts',
      home: './src/home.ts'
  },

webpack.prod.conf.js

 plugins: [
    new HtmlWebpackPlugin({         
      filename: config.build.index,
      template: 'index.html',
      inject: true,
      //chunks这个参数告诉插件要引用entry里面的哪几个入口
      chunks:['index'],      //这里设置以后报错,提示 webpackJsonp is not 
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true

    
      },
     
      chunksSortMode: 'dependency'
        }),
      new HtmlWebpackPlugin({          //另外一个入口文件
      filename: config.build.home,
      template: 'home.html',
      inject: true,
      //chunks这个参数告诉插件要引用entry里面的哪几个入口
      chunks:["home"],         //这里设置以后报错,提示 webpackJsonp is not defined                      
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
       
      },
    CommonsChunkPlugin
      chunksSortMode: 'dependency'
       
    }),

不知道是缺少其他配置还是什么原因,谢谢大家的解答,感激不尽

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全員に返信(1)
迷茫

你的commonChunk也要放进chunks里面的

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!