forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.html.js
More file actions
34 lines (29 loc) · 1.01 KB
/
inject.html.js
File metadata and controls
34 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { join } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const appPaths = require('../app-paths')
const HtmlAddonsPlugin = require('./plugin.html-addons').plugin
function getHtmlFilename (cfg) {
if (cfg.ctx.mode.ssr && cfg.ctx.mode.pwa) {
return cfg.ctx.dev
? cfg.build.ssrPwaHtmlFilename
: join(cfg.build.distDir, 'www', cfg.build.ssrPwaHtmlFilename)
}
return cfg.ctx.dev
? cfg.build.htmlFilename
: join(cfg.build.distDir, cfg.build.htmlFilename)
}
module.exports = function (chain, cfg, templateParam) {
chain.plugin('html-webpack')
.use(HtmlWebpackPlugin, [{
filename: getHtmlFilename(cfg),
template: appPaths.resolve.app(cfg.sourceFiles.indexHtmlTemplate),
minify: cfg.__html.minifyOptions,
templateParameters: templateParam || cfg.htmlVariables,
chunksSortMode: 'none',
// inject script tags for bundle
inject: true,
cache: true
}])
chain.plugin('html-addons')
.use(HtmlAddonsPlugin, [ cfg ])
}