I have the following
new HtmlwebpackPlugin({
title: 'Title',
template: 'index.template.ejs',
inject: 'body',
}),
which works perfectly under "webpack": "^1.12.12" but when trying with "webpack": "^2.0.5-beta" it fails
ERROR in Error: Child compilation failed:
Module parse failed: /bla/node_modules/html-webpack-plugin/lib/loader.js /bla/node_modules/u nderscore-template-loader/index.js /bla/index.template.ejs 'with' in strict mode (4:0)
You may need an appropriate loader to handle this file type.
| obj || (obj = {});
| var __t, __p = '';
| with (obj) {
| __p += '<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>\n <meta name="viewport" conte nt="width=device-width, user-scalable=no">\n <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" /> \n <title>' +
| ((__t = ( htmlWebpackPlugin.options.title )) == null ? '' : __t) +:
SyntaxError: 'with' in strict mode (4:0)
I've tried adding the loaders for ejs / html specificaly
{ test: /\.(html)$/, loader: "html-loader" },
{ test: /\.(ejs)$/, loader: "underscore-template-loader" },
But with doing that, it compiles, but the ejs isn't even parsed anymore. Rendering my title as <title><%= htmlWebpackPlugin.options.title %></title>
Any ideas ?
+1
Right now I don't have the time to get into webpack 2.
If you can gather more insights than error reports I might assist.
Just update your devDependency to allow < 3.
?
You are requiring webpack 1.something in your package.json. Change this line: https://github.com/ampedandwired/html-webpack-plugin/blob/master/package.json#L47
to ">1.12.10 < 3". I think that is the syntax but I'm not 100% sure.
Nothing really changed in this regard you just have to allow your package to be installable alongside webpack 2.
Does this really make a difference? It's just a dev dependency and not related to the bug described above.
Maybe not.
@Elyx0 et al, I got webpack 2.0.5-beta and webpack-dev-server from master to work by switching to the jade-loader without any problems.
I did this after trying the ejs-loader which fails because somehow it thinks it's being used in 'strict mode' and I couldn't figure out how to turn it off without hacking the source.
Anyway, the jade engine works just fine. I'm suspect others prob too...
Best.
Can I close this?
Hi, I upgraded webpack from 1 to latest 2.2.0-rc.3, and when using with the template option, the webpack bundle is broken.
xxxxx/node_modules/webpack/lib/Compilation.js:313
if(_this.profile) {
^
TypeError: Cannot read property 'profile' of null
@xiaobuu Same here, updated cli version in angular 2 project and " TypeError: Cannot read property 'profile' of null " error
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi, I upgraded webpack from 1 to latest 2.2.0-rc.3, and when using with the template option, the webpack bundle is broken.