@dotcom-tool-kit/webpack 2.0.0 → 2.1.0

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 CHANGED
@@ -2,3 +2,4 @@ hooks:
2
2
  'build:local': WebpackDevelopment
3
3
  'build:ci': WebpackProduction
4
4
  'build:remote': WebpackProduction
5
+ 'run:local': WebpackWatch
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,qBAAqB,CAAA;AAGpD,eAAO,MAAM,KAAK,+BAA0C,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
- exports.tasks = [development_1.default, production_1.default];
7
+ const watch_1 = (0, tslib_1.__importDefault)(require("./tasks/watch"));
8
+ exports.tasks = [development_1.default, production_1.default, watch_1.default];
@@ -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 default function runWebpack(logger: Logger, options: WebpackOptions): Promise<void>;
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
@@ -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,CASzF"}
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"}
@@ -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,SAAkB;IAE9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAM3B"}
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"}
@@ -12,4 +12,4 @@ class WebpackDevelopment extends types_1.Task {
12
12
  }
13
13
  }
14
14
  exports.default = WebpackDevelopment;
15
- WebpackDevelopment.description = 'build webpack';
15
+ WebpackDevelopment.description = 'Run Webpack in development mode';
@@ -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,SAAkB;IAE9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAM3B"}
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"}
@@ -12,4 +12,4 @@ class WebpackProduction extends types_1.Task {
12
12
  }
13
13
  }
14
14
  exports.default = WebpackProduction;
15
- WebpackProduction.description = 'build webpack';
15
+ WebpackProduction.description = 'Run Webpack in production mode';
@@ -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": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "main": "lib",
5
5
  "description": "",
6
6
  "author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@dotcom-tool-kit/error": "^2.0.0",
21
21
  "@dotcom-tool-kit/logger": "^2.0.0",
22
- "@dotcom-tool-kit/types": "^2.0.0",
22
+ "@dotcom-tool-kit/types": "^2.1.0",
23
23
  "webpack-cli": "^4.6.0"
24
24
  },
25
25
  "peerDependencies": {
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` |