diff --git a/node_modules/accepts/index.js b/node_modules/accepts/index.js index e9b2f63fb16f8ecdeb16c8eced302612794ccf65..efe502f5a92159ff50ff6679a83abcbce048ad0c 100644 --- a/node_modules/accepts/index.js +++ b/node_modules/accepts/index.js @@ -29,7 +29,7 @@ module.exports = Accepts * @public */ -function Accepts (req) { +function Accepts(req) { if (!(this instanceof Accepts)) { return new Accepts(req) } @@ -80,35 +80,35 @@ function Accepts (req) { */ Accepts.prototype.type = -Accepts.prototype.types = function (types_) { - var types = types_ - - // support flattened arguments - if (types && !Array.isArray(types)) { - types = new Array(arguments.length) - for (var i = 0; i < types.length; i++) { - types[i] = arguments[i] + Accepts.prototype.types = function (types_) { + var types = types_ + + // support flattened arguments + if (types && !Array.isArray(types)) { + types = new Array(arguments.length) + for (var i = 0; i < types.length; i++) { + types[i] = arguments[i] + } } - } - // no types, return all requested types - if (!types || types.length === 0) { - return this.negotiator.mediaTypes() - } + // no types, return all requested types + if (!types || types.length === 0) { + return this.negotiator.mediaTypes() + } - // no accept header, return first given type - if (!this.headers.accept) { - return types[0] - } + // no accept header, return first given type + if (!this.headers.accept) { + return types[0] + } - var mimes = types.map(extToMime) - var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) - var first = accepts[0] + var mimes = types.map(extToMime) + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) + var first = accepts[0] - return first - ? types[mimes.indexOf(first)] - : false -} + return first ? + types[mimes.indexOf(first)] : + false + } /** * Return accepted encodings or best fit based on `encodings`. @@ -124,24 +124,24 @@ Accepts.prototype.types = function (types_) { */ Accepts.prototype.encoding = -Accepts.prototype.encodings = function (encodings_) { - var encodings = encodings_ - - // support flattened arguments - if (encodings && !Array.isArray(encodings)) { - encodings = new Array(arguments.length) - for (var i = 0; i < encodings.length; i++) { - encodings[i] = arguments[i] + Accepts.prototype.encodings = function (encodings_) { + var encodings = encodings_ + + // support flattened arguments + if (encodings && !Array.isArray(encodings)) { + encodings = new Array(arguments.length) + for (var i = 0; i < encodings.length; i++) { + encodings[i] = arguments[i] + } } - } - // no encodings, return all requested encodings - if (!encodings || encodings.length === 0) { - return this.negotiator.encodings() - } + // no encodings, return all requested encodings + if (!encodings || encodings.length === 0) { + return this.negotiator.encodings() + } - return this.negotiator.encodings(encodings)[0] || false -} + return this.negotiator.encodings(encodings)[0] || false + } /** * Return accepted charsets or best fit based on `charsets`. @@ -157,24 +157,24 @@ Accepts.prototype.encodings = function (encodings_) { */ Accepts.prototype.charset = -Accepts.prototype.charsets = function (charsets_) { - var charsets = charsets_ - - // support flattened arguments - if (charsets && !Array.isArray(charsets)) { - charsets = new Array(arguments.length) - for (var i = 0; i < charsets.length; i++) { - charsets[i] = arguments[i] + Accepts.prototype.charsets = function (charsets_) { + var charsets = charsets_ + + // support flattened arguments + if (charsets && !Array.isArray(charsets)) { + charsets = new Array(arguments.length) + for (var i = 0; i < charsets.length; i++) { + charsets[i] = arguments[i] + } } - } - // no charsets, return all requested charsets - if (!charsets || charsets.length === 0) { - return this.negotiator.charsets() - } + // no charsets, return all requested charsets + if (!charsets || charsets.length === 0) { + return this.negotiator.charsets() + } - return this.negotiator.charsets(charsets)[0] || false -} + return this.negotiator.charsets(charsets)[0] || false + } /** * Return accepted languages or best fit based on `langs`. @@ -190,26 +190,26 @@ Accepts.prototype.charsets = function (charsets_) { */ Accepts.prototype.lang = -Accepts.prototype.langs = -Accepts.prototype.language = -Accepts.prototype.languages = function (languages_) { - var languages = languages_ - - // support flattened arguments - if (languages && !Array.isArray(languages)) { - languages = new Array(arguments.length) - for (var i = 0; i < languages.length; i++) { - languages[i] = arguments[i] + Accepts.prototype.langs = + Accepts.prototype.language = + Accepts.prototype.languages = function (languages_) { + var languages = languages_ + + // support flattened arguments + if (languages && !Array.isArray(languages)) { + languages = new Array(arguments.length) + for (var i = 0; i < languages.length; i++) { + languages[i] = arguments[i] + } } - } - // no languages, return all requested languages - if (!languages || languages.length === 0) { - return this.negotiator.languages() - } + // no languages, return all requested languages + if (!languages || languages.length === 0) { + return this.negotiator.languages() + } - return this.negotiator.languages(languages)[0] || false -} + return this.negotiator.languages(languages)[0] || false + } /** * Convert extnames to mime. @@ -219,10 +219,10 @@ Accepts.prototype.languages = function (languages_) { * @private */ -function extToMime (type) { - return type.indexOf('/') === -1 - ? mime.lookup(type) - : type +function extToMime(type) { + return type.indexOf('/') === -1 ? + mime.lookup(type) : + type } /** @@ -233,6 +233,6 @@ function extToMime (type) { * @private */ -function validMime (type) { +function validMime(type) { return typeof type === 'string' -} +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 9869a936dd6779f705d4f0d409ffcbbd24790a68..261f3386ac56bbdca951846f090713d2a35f94a3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,11 @@ +/* + * @Author: 尹鹏孝 + * @Date: 2018-09-07 16:38:01 + * @LastEditTime: 2021-10-12 21:09:12 + * @LastEditors: Please set LastEditors + * @Description: 操作webpack + * @FilePath: /web/webpack/src/index.js + */ import _ from 'lodash' import printMe from './print' import './index.css' @@ -23,7 +31,7 @@ function createDiv() { document.body.appendChild(createDiv()) if (module.hot) { - module.hot.accept('./print.js', function() { + module.hot.accept('./print.js', function () { console.log('热模块替换'); printMe(); }) diff --git a/webpack.config.dev.js b/webpack.config.dev.js new file mode 100644 index 0000000000000000000000000000000000000000..beac1709d312edd4bea380472f640b7da8800861 --- /dev/null +++ b/webpack.config.dev.js @@ -0,0 +1,37 @@ +/* + * @Author: 尹鹏孝 + * @Date: 2021-10-12 20:44:57 + * @LastEditTime: 2021-10-12 21:41:39 + * @LastEditors: Please set LastEditors + * @Description: 配置测试环节的webpack + * @FilePath: /web/webpack/webpack.config.dev.js + */ +const path = require('path'); +// require('style-loader!css-loader!./src/index.css?minimize') +const ExtractTextPlugin = require('mini-css-extract-plugin'); +modules.export = { + entry: './src/index.js', + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, './dist') + }, + module: { + rules: [{ + test: /\.css$/, + /* use: ['style-loader', 'css-loader?minimize', { + loader: 'css-loader', + options: { + minimize: true + } + }] */ + loaders: ExtractTextPlugin.extract({ + use: ['css-loader'] + }) + }] + }, + plugins: [ + new ExtractTextPlugin({ + filename: [`[name]_[contenthash:8].css`] + }) + ] +} \ No newline at end of file