Skip to content
Snippets Groups Projects
Commit a29c005e authored by Antoine Lambert's avatar Antoine Lambert
Browse files

generate-weblabels-webpack-plugin: Add absolute paths support in additionalScripts

parent a7fce92d
No related branches found
No related tags found
No related merge requests found
......@@ -160,4 +160,4 @@ An object declaring additional JavaScript assets loaded by your web application
}
```
The paths of the license and source files must be relative to the webpack project root folder.
\ No newline at end of file
If the path for a Javascript asset or a license file does not correspond to an url or does not start with '/', it is considered to be relative to the webpack project root folder.
\ No newline at end of file
......@@ -178,7 +178,7 @@ class GenerateWebLabelsPlugin {
if (this.options['additionalScripts']) {
for (let script of Object.keys(this.options['additionalScripts'])) {
let scriptFilesData = this.options['additionalScripts'][script];
if (script.indexOf('://') === -1) {
if (script.indexOf('://') === -1 && !script.startsWith('/')) {
script = stats.publicPath + script;
}
this.chunkJsAssetToSrcFiles[script] = [];
......@@ -192,7 +192,7 @@ class GenerateWebLabelsPlugin {
scriptSrcData['licenses'].forEach(license => {
license['copy_url'] = licenseCopyUrl;
});
if (scriptSrc['path'].indexOf('://') === -1) {
if (scriptSrc['path'].indexOf('://') === -1 && !scriptSrc['path'].startsWith('/')) {
scriptSrcData['src_url'] = stats.publicPath + path.join(this.weblabelsDirName, scriptSrc['id']);
} else {
scriptSrcData['src_url'] = scriptSrc['path'];
......@@ -355,7 +355,8 @@ class GenerateWebLabelsPlugin {
}
copyFileToOutputPath(srcFilePath, ext = '') {
if (this.copiedFiles.has(srcFilePath) || srcFilePath.indexOf('://') !== -1) {
if (this.copiedFiles.has(srcFilePath) || srcFilePath.indexOf('://') !== -1 ||
!fs.existsSync(srcFilePath)) {
return;
}
let destPath = this.cleanupPath(srcFilePath);
......
......@@ -39,7 +39,13 @@
let bundled_js_srcs = jslicenses_data[jsasset]; %>
<tr>
<td>
<a href="<%= jsasset %>"><%= jsasset.split('/').slice(-1)[0] %></a>
<a href="<%= jsasset %>">
<% if (jsasset.split('/').slice(-1)[0]) { %>
<%= jsasset.split('/').slice(-1)[0] %>
<% } else { %>
<%= jsasset %>
<% } %>
</a>
</td>
<td>
<% for (let i = 0; i < bundled_js_srcs.length ; ++i) {
......
......@@ -33,7 +33,11 @@ You can find the details of the content of each bundle in the <a href="https://w
{% for jsasset, bundled_js_srcs in jslicenses_data %}
<tr>
<td>
<a href="{{ jsasset }}">{{ jsasset | split:"/" | last }}</a>
{% if jsasset|split:"/"|last %}
<a href="{{ jsasset }}">{{ jsasset | split:"/" | last }}</a>
{% else %}
<a href="{{ jsasset }}">{{ jsasset }}</a>
{% endif %}
</td>
<td>
{% for js_src in bundled_js_srcs %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment