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sB,GAEjB,OAAO,EAAiB,YACzB,EAAkB,CAAC,GAEvB,EAAc,UAAY,CACtB,QAAQ,GAEZ,EAAc,QAAU,cAAc,EAAc,SACpD,EAAc,MAAQ,YAAY,EAAc,OAEhD,KAAK,cAAgB,EACrB,KAAK,gBAAkB,0BAA0B,EAAe,EACpE,CAEA,uBAAuB,UAAU,KAAO,SAAU,GAE9C,MAAM,cAAC,EAAa,gBAAE,GAAmB,KACnC,EAAW,QAAQ,GACzB,EAAa,OAAO,KAChB,IACW,kBAAkB,EAAU,KAG3C,EAAa,OAAO,KAChB,IACW,qBAAqB,IAGxC,EAEA,OAAO,QAAU","file":"/npm/foxman-plugin-webpack-dev-server@0.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/foxman-plugin-webpack-dev-server@0.1.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Created by june on 2017/1/14.\n */\n\"use strict\";\nconst webpackMiddleware = require(\"koa-webpack-dev-middleware\");\nconst WebpackHotMiddleware = require('koa-webpack-hot-middleware');\nconst webpack = require('webpack');\n\nconst typeOf = (obj, type) => {\n    return Object.prototype.toString.call(obj).toLowerCase().slice(8, -1) == type;\n};\n\nconst addDevModule = entry => {\n    if (!typeOf(entry, 'array')) {\n        entry = [entry];\n    }\n    entry.unshift('webpack/hot/dev-server');\n    entry.unshift('webpack-hot-middleware/client?reload=true');\n    return entry;\n};\n\nconst reducePlugins = plugins => {\n    if (!typeOf(plugins, 'array')) {\n        plugins = [];\n    }\n\n    plugins.push(new webpack.optimize.OccurrenceOrderPlugin());\n    plugins.push(new webpack.HotModuleReplacementPlugin());\n    plugins.push(new webpack.NoEmitOnErrorsPlugin());\n    return plugins\n};\n\nconst reduceEntry = entry => {\n    if (typeOf(entry, 'object')) {\n        for (let key in entry) {\n            if (entry.hasOwnProperty(key))\n                entry[key] = addDevModule(entry[key]);\n        }\n    } else if (typeOf(entry, 'array')) {\n        entry = addDevModule(entry);\n    } else if (typeOf(entry, 'string')) {\n        entry = addDevModule(entry);\n    }\n\n    return entry;\n};\n\nconst validateWebpackConfig = webpackConfig => {\n    if (!typeOf(webpackConfig, 'object')) {\n        throw new Error('webpackConfig must be object');\n    }\n\n    if (!typeOf(webpackConfig.output, 'object')) {\n        throw new Error('webpackConfig.output must be object');\n    }\n\n    if (!typeOf(webpackConfig.output.path, 'string')) {\n        throw new Error('webpackConfig.output.path must need');\n    }\n\n    if (!typeOf(webpackConfig.output.publicPath, 'string')) {\n        throw new Error('webpackConfig.output.publicPath must need');\n    }\n};\n\nconst getDefaultDevServerConfig = (webpackConfig, devServerConfig) => {\n    return Object.assign({\n        noInfo: false,  // display no info to console (only warnings and errors)\n        quiet: false,   // display nothing to the console\n        lazy: false,     // switch into lazy mode // that means no watching, but recompilation on every request\n        watchOptions: {\n            aggregateTimeout: 300\n        },\n        headers: {'X-Special-Static-Header': 'foxman'},\n        stats: {\n            colors: true\n        },\n        contentBase: webpackConfig.output.path,\n        publicPath: webpackConfig.output.publicPath,\n        hot: true\n    }, devServerConfig)\n};\n\nfunction WebpackDevServerPlugin({\n    webpackConfig,\n    devServerConfig\n}) {\n    validateWebpackConfig(webpackConfig);\n\n    if (!typeOf(devServerConfig, 'object')) {\n        devServerConfig = {}\n    }\n    webpackConfig.devServer = {\n        inline: true\n    };\n    webpackConfig.plugins = reducePlugins(webpackConfig.plugins);\n    webpackConfig.entry = reduceEntry(webpackConfig.entry);\n\n    this.webpackConfig = webpackConfig;\n    this.devServerConfig = getDefaultDevServerConfig(webpackConfig, devServerConfig);\n}\n\nWebpackDevServerPlugin.prototype.init = function (serverPlugin) {\n\n    const {webpackConfig, devServerConfig} = this;\n    const compiler = webpack(webpackConfig);\n    serverPlugin.server.use(\n        () => {\n            return webpackMiddleware(compiler, devServerConfig)\n        }\n    );\n    serverPlugin.server.use(\n        () => {\n            return WebpackHotMiddleware(compiler)\n        }\n    );\n};\n\nmodule.exports = WebpackDevServerPlugin;\n"]}