Gazebo_simulation-Frontend/node_modules/workbox-webpack-plugin/build/lib/relative-to-output-path.js
2020-12-21 10:29:31 -05:00

38 lines
1.2 KiB
JavaScript

'use strict';
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var path = require('path');
/**
* @param {Object} compilation The webpack compilation.
* @param {string} swDest The original swDest value.
*
* @return {string} If swDest was not absolute, the returns swDest as-is.
* Otheriwse, returns swDest relative to the compilation's output path.
*
* @private
*/
module.exports = function (compilation, swDest) {
// See https://github.com/jantimon/html-webpack-plugin/pull/266/files#diff-168726dbe96b3ce427e7fedce31bb0bcR38
if (path.resolve(swDest) === path.normalize(swDest)) {
return path.relative(compilation.options.output.path, swDest);
}
// Otherwise, return swDest as-is.
return swDest;
};