lcxfs1991 / html-res-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWplugin for generating html in webpack
plugin for generating html in webpack
我使用python的flask开发,使用的jinja2模板,需要把js插入到html指定的位置。能否这样实现呢:
<head>
<title>Inject point<title>
// chunk1插入的位置
<script src='another.js'></script>
// chunk2插入的位置
</head>
as title says
You can specify a subdirectory here too (eg: assets/admin.html).
My webpack config
new HtmlResWebpackPlugin({
mode: 'html',
filename: config.build.index,
template: "index.html",
inject: true,
chunks:
{
'app.js':{}
}
}),
And I meet a Error
Unhandled rejection TypeError: htmlContent.replace is not a function
I log the console.log(typeof compilation.assets[this.options.htmlFileName].source())
, it is a function, but it should be a string.
So How do I fix this error
Unhandled rejection TypeError: htmlContent.replace is not a function
at HtmlResWebpackPlugin.injectAssets (/Users/apple/Desktop/jdjob/xx/node_modules/html-res-webpack-plugin/index.js:434:28)
at Promise.resolve.then.then.then (/Users/apple/Desktop/jdjob/xx/node_modules/html-res-webpack-plugin/index.js:118:14)
at tryCatcher (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/Users/apple/Desktop/jdjob/xx/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)
Some project may only use webpack for js css and html. A customized output destination is needed.
应该怎么在什么时候插入呢? 怎么获取到webpack编译的代码呢?
Unhandled rejection TypeError: htmlContent.replace is not a
function
at HtmlResWebpackPlugin.apply.compiler.plugin.compiler.plugin.Promise.resolv
e.then.then.HtmlResWebpackPlugin.buildStatsHtmlMode.HtmlResWebpackPlugin.printCh
unkName.HtmlResWebpackPlugin.buildStats.HtmlResWebpackPlugin.checkResource.HtmlR
esWebpackPlugin.injectAssets.injectChunks.map [as injectAssets] (E:\git\erp\node
_modules\html-res-webpack-plugin\index.js:475:28)
想要html里面的img资源也支持md5怎么办呢? 现在${require('./img/logo.png')}
hash name should support more format.
In addition, the hash option should be modified
need to minify html
Trying on dev branch.
使用多个html文件的时候,有不需要编写node代码,根据路径就能分别访问相应的html的方法吗?
HtmlWebpackPlugin产出的文件生成的是index.html
index.html中引入的是main.[hash].js main.[hash].css
但是我的项目 想生成的是js文件 如sdk-load.js main.[hash].js main.[hash].css
sdk-load.js是我自定义的脚本 脚本内部想包含main.[hash].js main.[hash].css的文件名
请问能否支持产出js文件?
package.json:
"dependencies": {},
"devDependencies": {
"lodash": "^3.10.1",
"bluebird": "^3.1.1",
"html-minifier": "^1.1.1"
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.