課程
/前端開發
/前端工具
/webpack深入與實戰
我除了a頁面,其他的用chunks或者excludeChunks 都不行,是我用的假插件嗎
2017-03-09
源自:webpack深入與實戰 3-3
正在回答
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', ? ?}, ? ?output: { ? ? ? ?path : './dist',//打包出口 ? ? ? ?filename : 'js/[name]-[chunkhash].js',//打包輸出文件名稱 ? ? ? ?// publicPath : 'http://cdn.com/'//上線地址 ? ?}, ? ?plugins : [ ? ? ? ?new htmlWebpackPlugin({ ? ? ? ? ? ?filename : 'a.html',//生成的文件名稱 ? ? ? ? ? ?// filename : 'index-[hash].html', ? ? ? ? ? ?template : 'index.html',//模板文件 ? ? ? ? ? ?inject : 'body', // inject : 'body',//script標簽放置位置 ? ? ? ? ? ?title : '模板傳值a', ? ? ? ? ? ?// minify : {//壓縮 ? ? ? ? ? ?// ? ? removeComments : true,//刪除注釋 ? ? ? ? ? ?// ? ? collapseInlineTagWhitespace : true,//刪除空格 ? ? ? ? ? ?// }, ? ? ? ? ? ?excludeChunks :['b','c'], ? ? ? ?}), ? ? ? ?new htmlWebpackPlugin({ ? ? ? ? ? ?filename : 'b.html',//生成的文件名稱 ? ? ? ? ? ?// filename : 'index-[hash].html', ? ? ? ? ? ?template : 'index.html',//模板文件 ? ? ? ? ? ?inject : false, // inject : 'body',//script標簽放置位置 ? ? ? ? ? ?title : '模板傳值b!', ? ? ? ? ? ?excludeChunks :['b','c'], ? ? ? ?}), ? ? ? ?new htmlWebpackPlugin({ ? ? ? ? ? ?filename : 'c.html',//生成的文件名稱 ? ? ? ? ? ?// filename : 'index-[hash].html', ? ? ? ? ? ?template : 'index.html',//模板文件 ? ? ? ? ? ?inject : false, // inject : 'body',//script標簽放置位置 ? ? ? ? ? ?title : '模板傳值c!', ? ? ? ? ? ?excludeChunks :['b','c'], ? ? ? ?}), ? ?]}
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined
ERROR in ? TypeError: Cannot read property 'entry' of undefined
? - index.html:17226
? ? E:/demo2/index.html:17226:43
? - index.html:17231 module.exports
? ? E:/demo2/index.html:17231:3
? - index.js:265
? ? [demo2]/[html-webpack-plugin]/index.js:265:16
? - util.js:16 tryCatcher
? ? [demo2]/[bluebird]/js/release/util.js:16:23
? - promise.js:512 Promise._settlePromiseFromHandler
? ? [demo2]/[bluebird]/js/release/promise.js:512:31
? - promise.js:569 Promise._settlePromise
? ? [demo2]/[bluebird]/js/release/promise.js:569:18
? - promise.js:606 Promise._settlePromiseCtx
? ? [demo2]/[bluebird]/js/release/promise.js:606:10
? - async.js:138 Async._drainQueue
? ? [demo2]/[bluebird]/js/release/async.js:138:12
? - async.js:143 Async._drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:143:10
? - async.js:17 Immediate.Async.drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:17:14
舉報
webpack實戰教程,用真實項目帶你探索 webpack 強大的功能
3 回答chunks是什么?
12 回答為什么在webpack.config.js里plugin的里面,chunks這個會報錯
1 回答htmlWebpackPlugin.files里不存在chunks字段
2 回答js動態注入到html body中是 chunks 不等于 判斷符號
2 回答path報錯
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-03-09
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',
? ?},
? ?output: {
? ? ? ?path : './dist',//打包出口
? ? ? ?filename : 'js/[name]-[chunkhash].js',//打包輸出文件名稱
? ? ? ?// publicPath : 'http://cdn.com/'//上線地址
? ?},
? ?plugins : [
? ? ? ?new htmlWebpackPlugin({
? ? ? ? ? ?filename : 'a.html',//生成的文件名稱
? ? ? ? ? ?// filename : 'index-[hash].html',
? ? ? ? ? ?template : 'index.html',//模板文件
? ? ? ? ? ?inject : 'body', // inject : 'body',//script標簽放置位置
? ? ? ? ? ?title : '模板傳值a',
? ? ? ? ? ?// minify : {//壓縮
? ? ? ? ? ?// ? ? removeComments : true,//刪除注釋
? ? ? ? ? ?// ? ? collapseInlineTagWhitespace : true,//刪除空格
? ? ? ? ? ?// },
? ? ? ? ? ?excludeChunks :['b','c'],
? ? ? ?}),
? ? ? ?new htmlWebpackPlugin({
? ? ? ? ? ?filename : 'b.html',//生成的文件名稱
? ? ? ? ? ?// filename : 'index-[hash].html',
? ? ? ? ? ?template : 'index.html',//模板文件
? ? ? ? ? ?inject : false, // inject : 'body',//script標簽放置位置
? ? ? ? ? ?title : '模板傳值b!',
? ? ? ? ? ?excludeChunks :['b','c'],
? ? ? ?}),
? ? ? ?new htmlWebpackPlugin({
? ? ? ? ? ?filename : 'c.html',//生成的文件名稱
? ? ? ? ? ?// filename : 'index-[hash].html',
? ? ? ? ? ?template : 'index.html',//模板文件
? ? ? ? ? ?inject : false, // inject : 'body',//script標簽放置位置
? ? ? ? ? ?title : '模板傳值c!',
? ? ? ? ? ?excludeChunks :['b','c'],
? ? ? ?}),
? ?]
}
2017-03-09
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined
ERROR in ? TypeError: Cannot read property 'entry' of undefined
? - index.html:17226
? ? E:/demo2/index.html:17226:43
? - index.html:17231 module.exports
? ? E:/demo2/index.html:17231:3
? - index.js:265
? ? [demo2]/[html-webpack-plugin]/index.js:265:16
? - util.js:16 tryCatcher
? ? [demo2]/[bluebird]/js/release/util.js:16:23
? - promise.js:512 Promise._settlePromiseFromHandler
? ? [demo2]/[bluebird]/js/release/promise.js:512:31
? - promise.js:569 Promise._settlePromise
? ? [demo2]/[bluebird]/js/release/promise.js:569:18
? - promise.js:606 Promise._settlePromiseCtx
? ? [demo2]/[bluebird]/js/release/promise.js:606:10
? - async.js:138 Async._drainQueue
? ? [demo2]/[bluebird]/js/release/async.js:138:12
? - async.js:143 Async._drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:143:10
? - async.js:17 Immediate.Async.drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:17:14
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined
ERROR in ? TypeError: Cannot read property 'entry' of undefined
? - index.html:17226
? ? E:/demo2/index.html:17226:43
? - index.html:17231 module.exports
? ? E:/demo2/index.html:17231:3
? - index.js:265
? ? [demo2]/[html-webpack-plugin]/index.js:265:16
? - util.js:16 tryCatcher
? ? [demo2]/[bluebird]/js/release/util.js:16:23
? - promise.js:512 Promise._settlePromiseFromHandler
? ? [demo2]/[bluebird]/js/release/promise.js:512:31
? - promise.js:569 Promise._settlePromise
? ? [demo2]/[bluebird]/js/release/promise.js:569:18
? - promise.js:606 Promise._settlePromiseCtx
? ? [demo2]/[bluebird]/js/release/promise.js:606:10
? - async.js:138 Async._drainQueue
? ? [demo2]/[bluebird]/js/release/async.js:138:12
? - async.js:143 Async._drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:143:10
? - async.js:17 Immediate.Async.drainQueues
? ? [demo2]/[bluebird]/js/release/async.js:17:14