main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
949 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | */
|
---|
4 |
|
---|
5 | "use strict";
|
---|
6 |
|
---|
7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
---|
8 | const RuntimeModule = require("../RuntimeModule");
|
---|
9 |
|
---|
10 | /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
---|
11 | /** @typedef {import("../Compilation")} Compilation */
|
---|
12 |
|
---|
13 | class PublicPathRuntimeModule extends RuntimeModule {
|
---|
14 | /**
|
---|
15 | * @param {OutputOptions["publicPath"]} publicPath public path
|
---|
16 | */
|
---|
17 | constructor(publicPath) {
|
---|
18 | super("publicPath", RuntimeModule.STAGE_BASIC);
|
---|
19 | this.publicPath = publicPath;
|
---|
20 | }
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * @returns {string | null} runtime code
|
---|
24 | */
|
---|
25 | generate() {
|
---|
26 | const { publicPath } = this;
|
---|
27 | const compilation = /** @type {Compilation} */ (this.compilation);
|
---|
28 |
|
---|
29 | return `${RuntimeGlobals.publicPath} = ${JSON.stringify(
|
---|
30 | compilation.getPath(publicPath || "", {
|
---|
31 | hash: compilation.hash || "XXXX"
|
---|
32 | })
|
---|
33 | )};`;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | module.exports = PublicPathRuntimeModule;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.