UNPKG

2.87 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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
9var _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
11var _schemaUtils = require('schema-utils');
12
13var _schemaUtils2 = _interopRequireDefault(_schemaUtils);
14
15var _lodash = require('lodash.uniq');
16
17var _lodash2 = _interopRequireDefault(_lodash);
18
19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
23var 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'); // eslint-disable-line
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; // eslint-disable-line
49 }
50
51 if (dirs.length > 0) {
52 contextDepencies = (0, _lodash2.default)(contextDepencies.concat(dirs));
53 compilation.contextDepencies = contextDepencies; // eslint-disable-line
54 }
55 callback();
56 });
57 }
58 }]);
59
60 return ExtraWatchWebpackPlugin;
61}();
62
63ExtraWatchWebpackPlugin.defaults = {
64 cwd: process.cwd(),
65 files: [],
66 dirs: []
67};
68exports.default = ExtraWatchWebpackPlugin;
69module.exports = exports['default'];
\No newline at end of file