出现Cannot read property 'entry' of undefined错误的处理方法

var path = require("path");
var htmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
    entry: {
        main: './src/script/main.js',
        a: './src/script/a.js',
        b: './src/script/b.js',
        c: './src/script/c.js',
        d: './src/script/d.js',


    },
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'js/[name]-[chunkhash].js',
        publicPath: 'http://cdn.com/'
    },
    plugins: [
        new htmlWebpackPlugin({
            filename: 'a.html',
            template: "index.html",
            inject: false,
            title: 'this is a.html',
            data: new Date(),
            // chunks: ['a'],
            minify: {
                removeComments: true,
                collapseWhitespace: true
            }
           
        }),
        new htmlWebpackPlugin({
            filename: 'b.html',
            template: "index.html",
            inject: false,
            title: 'this is b.html',
            data: new Date(),
            // chunks: ['b'],
            minify: {
                removeComments: true,
                collapseWhitespace: true
            }
        }),
        new htmlWebpackPlugin({
            filename: 'c.html',
            template: "index.html",
            inject: 'body',
             title:'this is c.html',
            data: new Date(),
            chunks: ['main','c']
        }),
         new htmlWebpackPlugin({
            filename: 'd.html',
            template: "index.html",
            inject: 'body',
             title:'this is d.html',
            data: new Date(),
            // chunks: ['d']
        }),
    ]
}

c.html出现如下错误

Html Webpack Plugin:
<pre>
  TypeError: Cannot read property 'entry' of undefined
   
  - index.html:17237 
    D:/dwf/study/webpacklearn/index.html:17237:42
   
  - index.html:17240 module.exports
    D:/dwf/study/webpacklearn/index.html:17240:3
   
  - index.js:265 
    [webpacklearn]/[html-webpack-plugin]/index.js:265:16
   
  - util.js:16 tryCatcher
    [webpacklearn]/[bluebird]/js/release/util.js:16:23
   
  - promise.js:512 Promise._settlePromiseFromHandler
    [webpacklearn]/[bluebird]/js/release/promise.js:512:31
   
  - promise.js:569 Promise._settlePromise
    [webpacklearn]/[bluebird]/js/release/promise.js:569:18
   
  - promise.js:606 Promise._settlePromiseCtx
    [webpacklearn]/[bluebird]/js/release/promise.js:606:10
   
  - async.js:138 Async._drainQueue
    [webpacklearn]/[bluebird]/js/release/async.js:138:12
   
  - async.js:143 Async._drainQueues
    [webpacklearn]/[bluebird]/js/release/async.js:143:10
   
  - async.js:17 Immediate.Async.drainQueues
    [webpacklearn]/[bluebird]/js/release/async.js:17:14
   
</pre>

解决方法:

 把index.html引用了js,需要删除,注释掉没有用

 

转载于:https://www.cnblogs.com/chenmiaosong/p/7434871.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值