Skip to content

Commit

Permalink
CHANGE back to use html-webpack-plugin to keep compatibility with plu…
Browse files Browse the repository at this point in the history
…gin that depend on it.
  • Loading branch information
ndelangen committed Oct 12, 2018
1 parent 5dc9d9e commit ac2d7de
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 81 deletions.
2 changes: 1 addition & 1 deletion examples/polymer-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"devDependencies": {
"copy-webpack-plugin": "^4.5.3",
"html-webpack-plugin": "^3.2.0",
"html-webpack-plugin": "^4.0.0-beta.1",
"webpack-dev-server": "^3.1.9"
}
}
2 changes: 1 addition & 1 deletion lib/cli/test/fixtures/sfc_vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"friendly-errors-webpack-plugin": "^1.1.3",
"html-webpack-plugin": "^2.28.0",
"html-webpack-plugin": "^4.0.0-beta.1",
"http-proxy-middleware": "^0.17.3",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"express": "^4.16.3",
"file-loader": "^2.0.0",
"find-cache-dir": "^2.0.0",
"generate-page-webpack-plugin": "^1.1.1",
"global": "^4.3.2",
"html-webpack-plugin": "^4.0.0-beta.1",
"inquirer": "^6.2.0",
"interpret": "^1.1.0",
"ip": "^1.1.5",
Expand Down
36 changes: 21 additions & 15 deletions lib/core/src/server/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { getEnvironment } from 'universal-dotenv';
import Dotenv from 'dotenv-webpack';
import WatchMissingNodeModulesPlugin from 'react-dev-utils/WatchMissingNodeModulesPlugin';
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import GeneratePagePlugin from 'generate-page-webpack-plugin';

import HtmlWebpackPlugin from 'html-webpack-plugin';

import {
includePaths,
excludePaths,
Expand Down Expand Up @@ -42,20 +44,24 @@ export default ({ configDir, quiet, babelOptions, entries }) => {
publicPath: '',
},
plugins: [
new GeneratePagePlugin(
{
template: require.resolve('../templates/index.html.ejs'),
// eslint-disable-next-line global-require
parser: require('ejs'),
filename: entry => (entry === 'manager' ? 'index' : entry),
},
{
data: { version },
headHtmlSnippet: entry =>
entriesMeta[entry] ? entriesMeta[entry].headHtmlSnippet : null,
bodyHtmlSnippet: entry =>
entriesMeta[entry] ? entriesMeta[entry].bodyHtmlSnippet : null,
}
...Object.keys(entries).map(
e =>
new HtmlWebpackPlugin({
filename: `${e === 'manager' ? 'index' : e}.html`,
excludeChunks: Object.keys(entries).filter(i => i !== e),
chunksSortMode: 'none',
alwaysWriteToDisk: true,
inject: false,
templateParameters: (compilation, files, options) =>
console.log({ options, files }) || {
compilation,
files,
options,
version,
...entriesMeta[e],
},
template: require.resolve(`../templates/index.ejs`),
})
),
new webpack.DefinePlugin(loadEnv()),
new webpack.HotModuleReplacementPlugin(),
Expand Down
46 changes: 46 additions & 0 deletions lib/core/src/server/templates/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title><%= options.title || 'Storybook'%></title>

<% if (files.favicon) { %>
<link rel="shortcut icon" href="<%= files.favicon%>">
<% } %>

<% if (options.mobile) { %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<% } %>

<% if (typeof headHtmlSnippet !== 'undefined') { %>
<%= headHtmlSnippet %>
<% } %>

<% files.css.forEach(file => { %>
<link href="<%= file %>" rel="stylesheet">
<% }); %>

</head>
<body>

<% if (typeof bodyHtmlSnippet !== 'undefined') { %>
<%= bodyHtmlSnippet %>
<% } %>

<div id="root"></div>

<% if (options.window) { %>
<script>
<% for (var varName in options.window) { %>
window['<%=varName%>'] = <%= JSON.stringify(options.window[varName]) %>;
<% } %>
</script>
<% } %>

<% files.js.forEach(file => { %>
<script src="<%= file %>"></script>
<% }); %>

</body>
</html>
62 changes: 0 additions & 62 deletions lib/core/src/server/templates/index.html.ejs

This file was deleted.

22 changes: 21 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,13 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@ndelangen/html-webpack-harddisk-plugin@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@ndelangen/html-webpack-harddisk-plugin/-/html-webpack-harddisk-plugin-0.2.0.tgz#d2eb570597c83c1aa93d1f2fcb3d874a5855de07"
integrity sha512-55Mo2b5WtIT0l653y6ocu7C6QzznbasEnlixGzA26WK8Fj81wuEY3xf5N5bNAvDVfrwTLIPTXdEUGgPdrPLszw==
dependencies:
mkdirp "^0.5.1"

"@ngrx/store@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@ngrx/store/-/store-6.1.0.tgz#5b027647a797bf027912568214b10375dd75af38"
Expand Down Expand Up @@ -11348,7 +11355,7 @@ [email protected]:
tapable "^1.0.0"
util.promisify "1.0.0"

html-webpack-plugin@^3.0.6, html-webpack-plugin@^3.2.0:
html-webpack-plugin@^3.0.6:
version "3.2.0"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b"
integrity sha1-sBq71yOsqqeze2r0SS69oD2d03s=
Expand All @@ -11361,6 +11368,19 @@ html-webpack-plugin@^3.0.6, html-webpack-plugin@^3.2.0:
toposort "^1.0.0"
util.promisify "1.0.0"

html-webpack-plugin@^4.0.0-beta.1:
version "4.0.0-beta.1"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-4.0.0-beta.1.tgz#15b3b3634af47c79ac46c185f64e2007e0b0d14c"
integrity sha512-O+stuSCY5rdzX5O1l1FdH1bZqRQ7ybTi12OHzgD8u5Ogu2Usu3K7e633vxj4uOjM49ST+qCcu5rWYhqNKlpomQ==
dependencies:
"@types/tapable" "1.0.2"
html-minifier "^3.2.3"
loader-utils "^1.1.0"
lodash "^4.17.10"
pretty-error "^2.0.2"
tapable "^1.0.0"
util.promisify "1.0.0"

htmlescape@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/htmlescape/-/htmlescape-1.1.1.tgz#3a03edc2214bca3b66424a3e7959349509cb0351"
Expand Down

0 comments on commit ac2d7de

Please sign in to comment.