Skip to content

Commit 22de3d9

Browse files
committed
add evalPath
1 parent 05c4657 commit 22de3d9

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ process.on('message', (message) => {});
5858
|:--:|:--:|:-----:|:----------|
5959
|[**`name`**](#name)|`{String}`|`[hash].fork.js`|Set a custom name for the output script|
6060
|[**`publicPath`**](#publicPath)|`{String}`|`null`|Override the path from which fork scripts are downloaded|
61+
|[**`evalPath`**](#publicPath)|`{Boolean}`|`null`|if `publicPath` is treat as a static `String`|
62+
6163

6264
### `name`
6365

@@ -84,6 +86,18 @@ webpack assets is used
8486
}
8587
```
8688

89+
### `evalPath`
90+
91+
if wants to get dynamic publicPath like '__dirname', you should set `evalPath = true`
92+
93+
**webpack.config.js**
94+
```js
95+
{
96+
loader: 'webpack-fork-loader'
97+
options: { publicPath: '__dirname + "/"', evalPath: true }
98+
}
99+
```
100+
87101
## License
88102

89103
#### [MIT](./LICENSE)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-fork-loader",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"author": "githoniel",
55
"description": "fork loader module for webpack packing electron",
66
"repository": "https://github.com/githoniel/webpack-fork-loader.git",

src/options.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
},
77
"publicPath": {
88
"type": "string"
9+
},
10+
"evalPath": {
11+
"type": "boolean"
912
}
1013
},
1114
"additionalProperties": false

src/workers/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/* eslint-disable multiline-ternary */
22
const getWorker = (file, content, options) => {
3-
const publicPath = options.publicPath
4-
? JSON.stringify(options.publicPath)
5-
: '__webpack_public_path__';
3+
let publicPath;
4+
if (options.publicPath) {
5+
publicPath = options.evalPath ? options.publicPath : JSON.stringify(options.publicPath);
6+
} else {
7+
publicPath = '__webpack_public_path__';
8+
}
69

710
const publicWorkerPath = `${publicPath} + ${JSON.stringify(file)}`;
811

0 commit comments

Comments
 (0)