* Helper to return the absolute template path with a fallback loader * * @private * @param {string} template The path to the template e.g. './index.html' * @param {string} context The webpack base resolution path for relative paths e.g. process.cwd()
(template, context)
| 317 | * @param {string} context The webpack base resolution path for relative paths e.g. process.cwd() |
| 318 | */ |
| 319 | getTemplatePath(template, context) { |
| 320 | if (template === "auto") { |
| 321 | template = path.resolve(context, "src/index.ejs"); |
| 322 | if (!fs.existsSync(template)) { |
| 323 | template = path.join(__dirname, "default_index.ejs"); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | // If the template doesn't use a loader use the lodash template loader |
| 328 | if (template.indexOf("!") === -1) { |
| 329 | template = |
| 330 | require.resolve("./lib/loader.js") + |
| 331 | "!" + |
| 332 | path.resolve(context, template); |
| 333 | } |
| 334 | |
| 335 | // Resolve template path |
| 336 | return template.replace( |
| 337 | /([!])([^/\\][^!?]+|[^/\\!?])($|\?[^!?\n]+$)/, |
| 338 | (match, prefix, filepath, postfix) => |
| 339 | prefix + path.resolve(filepath) + postfix, |
| 340 | ); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Return all chunks from the compilation result which match the exclude and include filters |