resolve-webpack-url.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. /*
  3. Copyright 2018 Google LLC
  4. Use of this source code is governed by an MIT-style
  5. license that can be found in the LICENSE file or at
  6. https://opensource.org/licenses/MIT.
  7. */
  8. Object.defineProperty(exports, "__esModule", { value: true });
  9. exports.resolveWebpackURL = void 0;
  10. /**
  11. * Resolves a url in the way that webpack would (with string concatenation)
  12. *
  13. * Use publicPath + filePath instead of url.resolve(publicPath, filePath) see:
  14. * https://webpack.js.org/configuration/output/#output-publicpath
  15. *
  16. * @function resolveWebpackURL
  17. * @param {string} publicPath The publicPath value from webpack's compilation.
  18. * @param {Array<string>} paths File paths to join
  19. * @return {string} Joined file path
  20. *
  21. * @private
  22. */
  23. function resolveWebpackURL(publicPath, ...paths) {
  24. // This is a change in webpack v5.
  25. // See https://github.com/jantimon/html-webpack-plugin/pull/1516
  26. if (publicPath === 'auto') {
  27. return paths.join('');
  28. }
  29. else {
  30. return [publicPath, ...paths].join('');
  31. }
  32. }
  33. exports.resolveWebpackURL = resolveWebpackURL;