UNPKG

bisheng

Version:

Transform Markdown(and other static files with transformers) into a SPA website using React.

71 lines (55 loc) 3.45 kB
"use strict"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } // We should use `stats` props of webpack. But it not work in v4. var CleanUpStatsPlugin = /*#__PURE__*/function () { function CleanUpStatsPlugin(option) { _classCallCheck(this, CleanUpStatsPlugin); this.option = _objectSpread({ MiniCSSExtractPlugin: true, tsLoader: true }, option); } _createClass(CleanUpStatsPlugin, [{ key: "shouldPickStatChild", value: function shouldPickStatChild(child) { var MiniCSSExtractPlugin = this.option.MiniCSSExtractPlugin; if (MiniCSSExtractPlugin && child.name.includes('mini-css-extract-plugin')) return false; return true; } }, { key: "shouldPickWarning", value: function shouldPickWarning(message) { var tsLoader = this.option.tsLoader; if (tsLoader && /export .* was not found in .*/.test(message)) { return false; } return true; } }, { key: "apply", value: function apply(compiler) { var _this = this; compiler.hooks.afterCompile.tap('CleanUpStatsPlugin', function (compilation) { var children = compilation.children, warnings = compilation.warnings; if (Array.isArray(children)) { compilation.children = children.filter(function (child) { return _this.shouldPickStatChild(child); }); } if (Array.isArray(warnings)) { compilation.warnings = warnings.filter(function (message) { return _this.shouldPickWarning(message); }); } }); } }]); return CleanUpStatsPlugin; }(); module.exports = CleanUpStatsPlugin;