incompatibility with html-webpack-inline-source-plugin
See original GitHub issueHi, I’m trying to add dynamic cdn support for my repo but I encounter this error:
ERROR in Cannot read property 'map' of undefined
ERROR in TypeError: Cannot read property 'options' of undefined
- index.js:23
[templates_generator]/[html-webpack-inline-source-plugin]/index.js:23:36
- new Promise
- Hook.js:35 AsyncSeriesWaterfallHook.lazyCompileHook [as _promise]
[templates_generator]/[tapable]/lib/Hook.js:35:21
- index.js:673
[templates_generator]/[html-webpack-plugin]/index.js:673:47
- index.js:187 Promise.resolve.then.then.then.then.then.then.then.result
[templates_generator]/[html-webpack-plugin]/index.js:187:18
- next_tick.js:188 process._tickCallback
internal/process/next_tick.js:188:7
Everything was working fine before I added dynamic-cdn and this is my plugins section (ignore the dynamic entry suport) I saw in the code that this plugin applies the HTMLwbepack plugin and I suspect that this causes the inline-source-plugin to not work.
new HtmlWebpackPlugin({
template: entry.template,
filename: `${entry.chunkName}.html`,
inlineSource: entry.splitBundle ? `(runtime.*.js$|DL.*.js$|${entry.chunkName}.*.css$)` : '.(js|css)$',
inject: 'head',
chunksSortMode: entry.splitBundle ? function (a, b) {
let orders = ['runtime', 'DL', 'vendor', entry.chunkName]
if (orders.indexOf(a.names[0]) > orders.indexOf(b.names[0])) {
return 1
} else if (orders.indexOf(a.names[0]) < orders.indexOf(b.names[0])) {
return -1
} else {
return 0
}
} : () => 0
}),
new DynamicCdnWebpackPlugin({
only: ['react', 'react-dom']
}),
versions
"dynamic-cdn-webpack-plugin": "^4.0.0-rc.1",
"html-webpack-inline-source-plugin": "^0.0.10",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.5.0",
It would be great to be able to use both plugins, Thanks for the hard workd on this project!
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Inline JavaScript and CSS with webpack - Stack Overflow
Use InlineChunkHtmlPlugin from react-dev-utils const HtmlWebpackPlugin = require('html-webpack-plugin'); const InlineChunkHtmlPlugin ...
Read more >html-webpack-inline-source-plugin - npm
Embed javascript and css source inline when using the webpack dev server or middleware. Latest version: 0.0.10, last published: 5 years ago.
Read more >vuepress-html-webpack-plugin | Yarn - Package Manager
This is published as vuepress-html-webpack-plugin to be used in VuePress. ... up requiring the internal modules from the incompatible version of webpack.
Read more >Html-webpack-plugin NPM
source () (see the inline template example). The template can also be directly inlined directly into the options object. ⚠️ templateContent does not...
Read more >sass-loader - webpack - JS.ORG
Using ~ is deprecated and can be removed from your code (we recommend it), but we still support it for historical reasons. Why...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue. I want big dependencies to be fetched from CDN while keeping my code inline.
The key is to modify the
inlineSource
to only include sources that are local.Here is how I fixed it:
@njzjz I hope this is helpful.
@id0Sch Sorry for the delay, I don’t think there is a real solution here as if you try to in-line the JS, you are loosing the benefit of this plugin
https://github.com/DustinJackson/html-webpack-inline-source-plugin#basic-usage has a
inlineSource
options that should be used to not include url starting by https://unpkg.com/#/I wonder if we can make the error more explicit Maybe we should set
source
to throw when called?