mmiller42 / html-webpack-externals-plugin

Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.
MIT License
99 stars 16 forks source link

bootstrap.js must need global? #16

Closed xueyuchen closed 7 years ago

xueyuchen commented 7 years ago

code:

new HtmlWebpackExternalsPlugin({
        externals: [
          {
          //   module: 'jquery',
          //   entry: '//unpkg.com/jquery@3.2.1/dist/jquery.min.js',
          //   global: '$',
          // }, {
            module: 'bootstrap.min.js',
            entry: {path: '//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js', type: 'js'},
          }, {
            module: 'bootstrap.min.css',
            entry: {path: '//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css', type: 'css'},
          // }, {
          //   module: 'react',
          //   entry: {path: '//cdn.bootcss.com/react/0.14.8/react.min.js', type: 'js'},
          //   global: 'React'
          // }, {
          //   module: 'react-dom',
          //   entry: {path: '//cdn.bootcss.com/react/0.14.8/react-dom.min.js', type: 'js'},
          //   global: 'ReactDOM'
          }
        ],
        files: ['../../../view/front/test_index.html', '../../../view/front/test_detail.html'],
      })

error: ERROR in chunk test_index_renderer [entry] js/[name].bundle.js Cannot read property 'var' of null Child html-webpack-plugin for "../../../view/front/test_index.html":

question: option.externals[].global: For modules without an export (such as CSS), omit this property or use null, js such as bootstrap.min.js alse need global?

mmiller42 commented 7 years ago

"Cannot read property 'var' of null" sounds like version 2 of html-webpack-externals-plugin. Can you verify that you are running the latest version, 3.3.5?

mmiller42 commented 7 years ago

To answer your question, no, modules like bootstrap.min.js do not need a global, as they don't directly export anything (instead they just mutate the global jQuery object).

Were you able to check if you're running the correct version of HtmlWebpackExternalsPlugin?