1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
8 |
|
9 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
10 |
|
11 | var _schemaUtils = require('schema-utils');
|
12 |
|
13 | var _schemaUtils2 = _interopRequireDefault(_schemaUtils);
|
14 |
|
15 | var _lodash = require('lodash.uniq');
|
16 |
|
17 | var _lodash2 = _interopRequireDefault(_lodash);
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
22 |
|
23 | var ExtraWatchWebpackPlugin = function () {
|
24 | function ExtraWatchWebpackPlugin() {
|
25 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
26 |
|
27 | _classCallCheck(this, ExtraWatchWebpackPlugin);
|
28 |
|
29 | (0, _schemaUtils2.default)(require('../options.json'), options, 'ExtraWatchWebpackPlugin');
|
30 | this.options = _extends({}, ExtraWatchWebpackPlugin.defaults, options);
|
31 | }
|
32 |
|
33 | _createClass(ExtraWatchWebpackPlugin, [{
|
34 | key: 'apply',
|
35 | value: function apply(compiler) {
|
36 | var _this = this;
|
37 |
|
38 | compiler.plugin('after-compile', function (compilation, callback) {
|
39 | var _options = _this.options,
|
40 | files = _options.files,
|
41 | dirs = _options.dirs;
|
42 | var fileDependencies = compilation.fileDependencies,
|
43 | contextDepencies = compilation.contextDepencies;
|
44 |
|
45 |
|
46 | if (files.length > 0) {
|
47 | fileDependencies = (0, _lodash2.default)(fileDependencies.concat(files));
|
48 | compilation.fileDependencies = fileDependencies;
|
49 | }
|
50 |
|
51 | if (dirs.length > 0) {
|
52 | contextDepencies = (0, _lodash2.default)(contextDepencies.concat(dirs));
|
53 | compilation.contextDepencies = contextDepencies;
|
54 | }
|
55 | callback();
|
56 | });
|
57 | }
|
58 | }]);
|
59 |
|
60 | return ExtraWatchWebpackPlugin;
|
61 | }();
|
62 |
|
63 | ExtraWatchWebpackPlugin.defaults = {
|
64 | cwd: process.cwd(),
|
65 | files: [],
|
66 | dirs: []
|
67 | };
|
68 | exports.default = ExtraWatchWebpackPlugin;
|
69 | module.exports = exports['default']; |
\ | No newline at end of file |