課程
/前端開發(fā)
/前端工具
/webpack深入與實(shí)戰(zhàn)
為何我script標(biāo)簽里寫<%=>會(huì)報(bào)錯(cuò),你們有遇到么?我運(yùn)行也能出結(jié)果
2017-03-13
源自:webpack深入與實(shí)戰(zhàn) 3-3
正在回答
可以用
來(lái)生成inline script
首先先用npm 安裝,然后再到webpack.config.js當(dāng)中引用
再在plugins當(dāng)中設(shè)置需要用內(nèi)斂方法嵌入的文件,然后新建source-plugin對(duì)象即可
const?htmlWebpackPlugin?=?require('html-webpack-plugin') const?HtmlWebpackInlineSourcePlugin?=?require('html-webpack-inline-source-plugin') ?plugins:?[ ????new?htmlWebpackPlugin({ ?????????filename:?'index.html',????? ?????????template:?'index.html',????? ?????????inject:?'head',???? ??????????inlineSource:?'.(main.js)$' ????}),??? ????????new?HtmlWebpackInlineSourcePlugin()? ?]
<script?type="text/html"> <%=compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source()%> </script>
內(nèi)心爆炸,不管了...
這個(gè)問(wèn)題知道是為嘛了沒?
b.html的配置中: excludeChunks:['a','c','main']改為excludeChunks:['a','c'], 也就是說(shuō)接口里用main.entry寫的方法(就是這段 <%=?compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source()?%>),那么在webpack.config文件中的excludeChunks里就不能把‘main’排除掉
求同,速度來(lái)人回答 ??。。。。。。。?!
你試試把有帶hash的去掉,估計(jì)就可以
<script type="text/javascript">?<%=compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %></script>
這句有報(bào)錯(cuò),很郁悶
木主0703
<%= %>少寫了個(gè)%號(hào)
舒戈丶2m
木主0703 回復(fù) 舒戈丶2m
舉報(bào)
webpack實(shí)戰(zhàn)教程,用真實(shí)項(xiàng)目帶你探索 webpack 強(qiáng)大的功能
2 回答webpack4中在html頁(yè)面的<script>標(biāo)簽里寫<%= %>會(huì)報(bào)下面的錯(cuò)誤,大家有遇到嗎
3 回答script標(biāo)簽里的<%= %>報(bào)錯(cuò)問(wèn)題怎么解決?
2 回答script標(biāo)簽插入<%=%>報(bào)錯(cuò) 怎么解決
7 回答webpack中 <script>標(biāo)簽中<%%>報(bào)錯(cuò)
2 回答運(yùn)行npm run webpack 報(bào)錯(cuò),直接運(yùn)行webpack不會(huì)報(bào)錯(cuò)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2019-03-13
可以用
html-webpack-inline-source-plugin
來(lái)生成inline script
首先先用npm 安裝,然后再到webpack.config.js當(dāng)中引用
再在plugins當(dāng)中設(shè)置需要用內(nèi)斂方法嵌入的文件,然后新建source-plugin對(duì)象即可
2018-10-22
2018-10-12
內(nèi)心爆炸,不管了...
2018-03-20
這個(gè)問(wèn)題知道是為嘛了沒?
2017-07-01
2017-05-06
求同,速度來(lái)人回答 ??。。。。。。。?!
2017-03-30
你試試把有帶hash的去掉,估計(jì)就可以
2017-03-14
<script type="text/javascript">
?<%=compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %>
</script>
這句有報(bào)錯(cuò),很郁悶
2017-03-13
<%= %>少寫了個(gè)%號(hào)