@dotcom-tool-kit/webpack 1.9.0 → 2.1.1
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/.toolkitrc.yml +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/run-webpack.d.ts +5 -1
- package/lib/run-webpack.d.ts.map +1 -1
- package/lib/run-webpack.js +3 -0
- package/lib/tasks/development.d.ts.map +1 -1
- package/lib/tasks/development.js +1 -1
- package/lib/tasks/production.d.ts.map +1 -1
- package/lib/tasks/production.js +1 -1
- package/lib/tasks/watch.d.ts +7 -0
- package/lib/tasks/watch.d.ts.map +1 -0
- package/lib/tasks/watch.js +17 -0
- package/package.json +7 -6
- package/readme.md +47 -0
package/.toolkitrc.yml
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,qBAAqB,CAAA;AAIpD,eAAO,MAAM,KAAK,+BAAwD,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -4,4 +4,5 @@ exports.tasks = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const development_1 = (0, tslib_1.__importDefault)(require("./tasks/development"));
|
|
6
6
|
const production_1 = (0, tslib_1.__importDefault)(require("./tasks/production"));
|
|
7
|
-
|
|
7
|
+
const watch_1 = (0, tslib_1.__importDefault)(require("./tasks/watch"));
|
|
8
|
+
exports.tasks = [development_1.default, production_1.default, watch_1.default];
|
package/lib/run-webpack.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Logger } from 'winston';
|
|
2
2
|
import type { WebpackOptions } from '@dotcom-tool-kit/types/lib/schema/webpack';
|
|
3
|
-
export
|
|
3
|
+
export interface RunWebpackOptions {
|
|
4
|
+
mode: 'production' | 'development';
|
|
5
|
+
watch?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function runWebpack(logger: Logger, options: WebpackOptions & RunWebpackOptions): Promise<void>;
|
|
4
8
|
//# sourceMappingURL=run-webpack.d.ts.map
|
package/lib/run-webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-webpack.d.ts","sourceRoot":"","sources":["../src/run-webpack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAK/E,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"run-webpack.d.ts","sourceRoot":"","sources":["../src/run-webpack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAK/E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,GAAG,aAAa,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7G"}
|
package/lib/run-webpack.js
CHANGED
|
@@ -9,6 +9,9 @@ function runWebpack(logger, options) {
|
|
|
9
9
|
if (options.configPath) {
|
|
10
10
|
args.push(`--config=${options.configPath}`);
|
|
11
11
|
}
|
|
12
|
+
if (options.watch) {
|
|
13
|
+
args.push('--watch');
|
|
14
|
+
}
|
|
12
15
|
const child = (0, child_process_1.fork)(webpackCLIPath, args, { silent: true });
|
|
13
16
|
(0, logger_1.hookFork)(logger, 'webpack', child);
|
|
14
17
|
return (0, logger_1.waitOnExit)('webpack', child);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development.d.ts","sourceRoot":"","sources":["../../src/tasks/development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,IAAI,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"development.d.ts","sourceRoot":"","sources":["../../src/tasks/development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,IAAI,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,SAAoC;IAEhD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAM3B"}
|
package/lib/tasks/development.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/tasks/production.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,IAAI,CAAC,OAAO,aAAa,CAAC;IACvE,MAAM,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/tasks/production.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,IAAI,CAAC,OAAO,aAAa,CAAC;IACvE,MAAM,CAAC,WAAW,SAAmC;IAE/C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAM3B"}
|
package/lib/tasks/production.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Task } from '@dotcom-tool-kit/types';
|
|
2
|
+
import { WebpackSchema } from '@dotcom-tool-kit/types/lib/schema/webpack';
|
|
3
|
+
export default class WebpackWatch extends Task<typeof WebpackSchema> {
|
|
4
|
+
static description: string;
|
|
5
|
+
run(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/tasks/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,IAAI,CAAC,OAAO,aAAa,CAAC;IAClE,MAAM,CAAC,WAAW,SAAgD;IAE5D,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const types_1 = require("@dotcom-tool-kit/types");
|
|
5
|
+
const run_webpack_1 = (0, tslib_1.__importDefault)(require("../run-webpack"));
|
|
6
|
+
class WebpackWatch extends types_1.Task {
|
|
7
|
+
async run() {
|
|
8
|
+
// don't wait for Webpack to exit, to leave it running in the background
|
|
9
|
+
(0, run_webpack_1.default)(this.logger, {
|
|
10
|
+
...this.options,
|
|
11
|
+
mode: 'development',
|
|
12
|
+
watch: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = WebpackWatch;
|
|
17
|
+
WebpackWatch.description = 'Run Webpack in watch mode in the background';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/webpack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"main": "lib",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"test": "cd ../../ ; npx jest --silent --projects plugins/webpack"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dotcom-tool-kit/error": "^
|
|
21
|
-
"@dotcom-tool-kit/logger": "^
|
|
22
|
-
"@dotcom-tool-kit/types": "^
|
|
20
|
+
"@dotcom-tool-kit/error": "^2.0.0",
|
|
21
|
+
"@dotcom-tool-kit/logger": "^2.0.0",
|
|
22
|
+
"@dotcom-tool-kit/types": "^2.2.0",
|
|
23
23
|
"webpack-cli": "^4.6.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"webpack": "4.x.x || 5.x.x"
|
|
26
|
+
"webpack": "4.x.x || 5.x.x",
|
|
27
|
+
"dotcom-tool-kit": "2.x"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@jest/globals": "^27.4.6",
|
|
@@ -38,4 +39,4 @@
|
|
|
38
39
|
"volta": {
|
|
39
40
|
"extends": "../../package.json"
|
|
40
41
|
}
|
|
41
|
-
}
|
|
42
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @dotcom-tool-kit/webpack
|
|
2
|
+
|
|
3
|
+
Tool Kit plugin to run [Webpack](https://webpack.js.org)
|
|
4
|
+
|
|
5
|
+
## Installation & usage
|
|
6
|
+
|
|
7
|
+
With Tool Kit [already set up](https://github.com/financial-times/dotcom-tool-kit#installing-and-using-tool-kit), install this plugin as a dev dependency:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install --save-dev @dotcom-tool-kit/webpack
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And add it to your repo's `.toolkitrc.yml`:
|
|
14
|
+
|
|
15
|
+
```yml
|
|
16
|
+
plugins:
|
|
17
|
+
- '@dotcom-tool-kit/webpack'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
You will need plugins that provides hooks to run the `Webpack*` tasks.
|
|
21
|
+
|
|
22
|
+
### Building with Webpack locally
|
|
23
|
+
|
|
24
|
+
For local development, by default the `WebpackDevelopment` task runs on the `build:local` hook, and `WebpackWatch` runs on `run:local`. One plugin that provides these hooks is [`npm`](../npm), allowing you to run Webpack with `npm run build` and `npm start`. `WebpackWatch` runs Webpack in the background, allowing it to run alongside your other tasks that run on `run:local`, which lets you run e.g. your app with the [`node`](../node) plugin in parallel with Webpack.
|
|
25
|
+
|
|
26
|
+
### Building with Webpack on CI and remote apps
|
|
27
|
+
|
|
28
|
+
The `WebpackProduction` task runs on the `build:ci` and `build:remote` hooks by default. `build:ci` is for compiling an app's source in CI jobs, and is provided by plugins like [`circleci`](../circleci/). `build:remote` compiles an app for running on a production or testing server, and can be provided by plugins like [`heroku`](../heroku/).
|
|
29
|
+
|
|
30
|
+
### Running on another hook
|
|
31
|
+
You can also configure Webpack to run on any other hook; for example, if you want to run it with `npm run test` via the `npm` plugin, you can manually configure Webpack to run on `npm`'s `test:local` hook:
|
|
32
|
+
|
|
33
|
+
```yml
|
|
34
|
+
plugins:
|
|
35
|
+
- '@dotcom-tool-kit/webpack'
|
|
36
|
+
- '@dotcom-tool-kit/npm'
|
|
37
|
+
hooks:
|
|
38
|
+
'test:local': WebpackDevelopment
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Tasks
|
|
42
|
+
|
|
43
|
+
| Task | Description | Default hooks |
|
|
44
|
+
|-|-|-|
|
|
45
|
+
| `WebpackDevelopment` | Run Webpack in development mode | `build:local` |
|
|
46
|
+
| `WebpackProduction` | Run Webpack in production mode | `build:ci`, `build:remote` |
|
|
47
|
+
| `WebpackWatch` | Run Webpack in watch mode in the background | `run:local` |
|