@rushstack/set-webpack-public-path-plugin 3.3.61 → 3.3.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +5 -6
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/set-webpack-public-path-plugin",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.62",
|
|
4
4
|
"description": "This plugin sets the webpack public path at runtime.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "dist/set-webpack-public-path-plugin.d.ts",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rushstack/webpack-plugin-utilities": "0.1.
|
|
26
|
+
"@rushstack/webpack-plugin-utilities": "0.1.29"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rushstack/eslint-config": "3.0.0",
|
|
30
30
|
"@rushstack/heft": "0.47.5",
|
|
31
|
-
"@rushstack/heft-node-rig": "1.10.
|
|
32
|
-
"@rushstack/heft-webpack5-plugin": "0.5.
|
|
31
|
+
"@rushstack/heft-node-rig": "1.10.6",
|
|
32
|
+
"@rushstack/heft-webpack5-plugin": "0.5.44",
|
|
33
33
|
"@types/heft-jest": "1.0.1",
|
|
34
34
|
"@types/node": "12.20.24",
|
|
35
35
|
"@types/tapable": "1.0.6",
|
|
@@ -38,6 +38,5 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "heft build --clean",
|
|
40
40
|
"_phase:build": "heft build --clean"
|
|
41
|
-
}
|
|
42
|
-
"readme": "# set-webpack-public-path plugin for webpack\n\n## Installation\n\n`npm install @rushstack/set-webpack-public-path-plugin --save-dev`\n\n## Overview\n\nThis simple plugin sets the `__webpack_public_path__` variable to\na value specified in the arguments, optionally appended to the SystemJs baseURL\nproperty.\n\n# Plugin\n\nTo use the plugin, add it to the `plugins` array of your Webpack config. For example:\n\n```JavaScript\nimport { SetPublicPathPlugin } from '@rushstack/set-webpack-public-path-plugin';\n\n{\n plugins: [\n new SetPublicPathPlugin( /* webpackPublicPathOptions */ )\n ]\n}\n```\n\n## Options\n\n#### `scriptName = { }`\n\nThis parameter is an object that takes three properties: a string property `name`, a boolean property `isTokenized`,\nand a boolean property `useAssetName`\n\nThe `name` property is a regular expression string that is applied to all script URLs on the page. The last directory\nof the URL that matches the regular expression is used as the public path. For example, if the `name` property\nis set to `my\\-bundle_?[a-zA-Z0-9-_]*\\.js` and a script's URL is `https://mycdn.net/files/build_id/assets/my-bundle_10fae182eb.js`,\nthe public path will be set to `https://mycdn.net/files/build_id/assets/`.\n\nIf the `isTokenized` parameter is set to `true`, the regular expression string in `name` is treated as a tokenized\nstring. The supported tokens are `[name]` and `[hash]`. Instances of the `[name]` substring are replaced with the\nchunk's name, and instances of the `[hash]` substring are replaced with the chunk's rendered hash. The name\nis regular expression-escaped. For example, if the `name` property is set to `[name]_?[a-zA-Z0-9-_]*\\.js`,\n`isTokenized` is set to `true`, and the chunk's name is `my-bundle`, and a script's URL is\n`https://mycdn.net/files/build_id/assets/my-bundle_10fae182eb.js`, the public path will be set to\n`https://mycdn.net/files/build_id/assets/`.\n\nIf the `useAssetName` property is set, the plugin will use the Webpack-produced asset name as it would the `name`\nproperty. `useAssetName` is exclusive to `name` and `isTokenized`.\n\nThis option is exclusive to other options. If it is set, `systemJs`, `publicPath`, and `urlPrefix` will be ignored.\n\n#### `systemJs = true`\n\nUse `System.baseURL` if it is defined.\n\n#### `publicPath = '...'`\n\nUse the specified path as the base public path. If `urlPrefix` is also defined, the public path will\nbe the concatenation of the two (i.e. - `__webpack_public_path__ = URL.concat({publicPath} + {urlPrefix}`).\nThis option takes precedence over the `systemJs` option.\n\n#### `urlPrefix = '...'`\n\nUse the specified string as a URL prefix after the SystemJS path or the `publicPath` option. If neither\n`systemJs` nor `publicPath` is defined, this option will not apply and an exception will be thrown.\n\n#### `regexVariable = '...'`\n\nCheck for a variable with name `...` on the page and use its value as a regular expression against script paths to\nthe bundle's script. If a value `foo` is passed into `regexVariable`, the produced bundle will look for a variable\ncalled `foo` during initialization, and if a `foo` variable is found, use its value as a regular expression to\ndetect the bundle's script.\n\nFor example, if the `regexVariable` option is set to `scriptRegex` and `scriptName` is set to `{ name: 'myscript' }`,\nconsider two cases:\n\n##### Case 1\n\n```HTML\n<html>\n <head>\n <script>\n var scriptRegex = /thescript/i;\n </script>\n <script src=\"theScript.js\"></script>\n </head>\n\n ...\n</html>\n```\n\nIn this case, because there is a `scriptRegex` variable defined on the page, the bundle will use its value\n(`/thescript/i`) to find the script.\n\n##### Case 2\n\n```HTML\n<html>\n <head>\n <script src=\"myScript.js\"></script>\n </head>\n\n ...\n</html>\n```\n\nIn this case, because there is not a `scriptRegex` variable defined on the page, the bundle will use the value\npassed into the `scriptName` option to find the script.\n\n#### `getPostProcessScript = (variableName) => { ... }`\n\nA function that returns a snippet of code that manipulates the variable with the name that's specified in the\nparameter. If this parameter isn't provided, no post-processing code is included. The variable must be modified\nin-place - the processed value should not be returned. This is useful when non-entry assets are deployed to\na parent directory or subdirectory of the directory to which the entry assets are deployed.\n\nFor example, if this parameter is set to this function\n\n```JavaScript\ngetPostProcessScript = (variableName) => {\n return `${variableName} = ${variableName} + 'assets/';`;\n};\n```\n\nthe public path variable will have `/assets/` appended to the found path.\n\nNote that the existing value of the variable already ends in a slash (`/`).\n\n#### `preferLastFoundScript = false`\n\nIf true, find the last script matching the regexVariable (if it is set). If false, find the first matching script.\nThis can be useful if there are multiple scripts loaded in the DOM that match the regexVariable.\n\n#### `skipDetection = false`\n\nIf true, always include the code snippet to detect the public path regardless of whether chunks or assets are present.\n\n# SystemJS Caveat\n\nWhen modules are loaded with SystemJS (and with the , `scriptLoad: true` meta option) `<script src=\"...\"></script>`\ntags are injected onto the page, evaludated and then immediately removed. This causes an issue because they are removed\nbefore webpack module code begins to execute, so the `publicPath=...` option won't work for modules loaded with SystemJS.\n\nTo circumvent this issue, a small bit of code is availble to that will maintain a global register of script paths\nthat have been inserted onto the page. This code block should be appended to bundles that are expected to be loaded\nwith SystemJS and use the `publicPath=...` option.\n\n## `getGlobalRegisterCode(bool)`\n\nThis function returns a block of JavaScript that maintains a global register of script tags. If the optional boolean parameter\nis set to `true`, the code is not minified. By default, it is minified. You can detect if the plugin may require\nthe global register code by searching for the value of the `registryVariableName` field.\n\n## Usage without registryVariableName\n\n``` javascript\nvar setWebpackPublicPath = require('@rushstack/set-webpack-public-path-plugin');\nvar gulpInsert = require('gulp-insert');\n\ngulp.src('finizlied/webpack/bundle/path')\n .pipe(gulpInsert.append(setWebpackPublicPath.getGlobalRegisterCode(true)))\n .pipe(gulp.dest('dest/path'));\n```\n\n## Usage with registryVariableName\n\n``` javascript\nvar setWebpackPublicPath = require('@rushstack/set-webpack-public-path-plugin');\nvar gulpInsert = require('gulp-insert');\nvar gulpIf = require('gulp-if');\n\nvar detectRegistryVariableName = function (file) {\n return file.contents.toString().indexOf(setWebpackPublicPath.registryVariableName) !== -1;\n};\n\ngulp.src('finizlied/webpack/bundle/path')\n .pipe(gulpIf(detectRegistryVariableName, gulpInsert.append(setWebpackPublicPath.getGlobalRegisterCode(true))))\n .pipe(gulp.dest('dest/path'));\n```\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/main/webpack/set-webpack-public-path-plugin/CHANGELOG.md) - Find\n out what's new in the latest version\n\n`@rushstack/set-webpack-public-path-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
|
|
41
|
+
}
|
|
43
42
|
}
|