Webpack不会对请求进行定义

问题描述 投票:1回答:1

我已经成功地使用Webpack构建了一个main.js.在我的项目文件夹中运行npx webpack之后,它在带有index.html的dist文件夹中创建了一个main.js.当我打开index.html并检查控制台时,它给了我这个错误...

ReferenceError: request is not defined[Learn More] main.js:651:2
    <anonymous> http://127.0.0.1:5500/src/main.js:651
    __webpack_require__ http://127.0.0.1:5500/src/main.js:556
    fn http://127.0.0.1:5500/src/main.js:87
    <anonymous> http://127.0.0.1:5500/src/main.js:588
    <anonymous> http://127.0.0.1:5500/src/main.js:586
    __webpack_require__ http://127.0.0.1:5500/src/main.js:556
    <anonymous> http://127.0.0.1:5500/src/main.js:579
    <anonymous> http://127.0.0.1:5500/src/main.js:1

我100%已包含请求。无论如何,你可以看看我之前的问题,你会发现我能够成功地使用请求从网站上抓取数据。所以request是我在node_modules文件夹中的库。这是我使用webpack后给我的main.js(在中间非常简单,所以我可以限制字数)。 (顺便说一句,651行一直在底部..行说“module.exports = request;”)

/******/                    module: moduleId,
/******/                    errorHandler: installedModules[moduleId].hot._selfAccepted
/******/                });
/******/        }
/******/    
/******/        // Now in "dispose" phase
/******/        hotSetStatus("dispose");
/******/        var queue = outdatedModules.slice();
/******/        while(queue.length > 0) {
/******/            var moduleId = queue.pop();
/******/            var module = installedModules[moduleId];
/******/            if(!module) continue;
/******/    
/******/            var data = {};
/******/    
/******/            // Call dispose handlers
/******/            var disposeHandlers = module.hot._disposeHandlers;
/******/            for(var j = 0; j < disposeHandlers.length; j++) {
/******/                var cb = disposeHandlers[j];
/******/                cb(data);
/******/            }
/******/            hotCurrentModuleData[moduleId] = data;
/******/    
/******/            // disable module (this disables requires from this module)
/******/            module.hot.active = false;
/******/    
/******/            // remove module from cache
/******/            delete installedModules[moduleId];
/******/    
/******/            // remove "parents" references from all children
/******/            for(var j = 0; j < module.children.length; j++) {
/******/                var child = installedModules[module.children[j]];
/******/                if(!child) continue;
/******/                var idx = child.parents.indexOf(moduleId);
/******/                if(idx >= 0) {
/******/                    child.parents.splice(idx, 1);
/******/                }
/******/            }
/******/        }
/******/    
/******/        // remove outdated dependency from module children
/******/        for(var moduleId in outdatedDependencies) {
/******/            if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
/******/                var module = installedModules[moduleId];
/******/                var moduleOutdatedDependencies = outdatedDependencies[moduleId];
/******/                for(var j = 0; j < moduleOutdatedDependencies.length; j++) {
/******/                    var dependency = moduleOutdatedDependencies[j];
/******/                    var idx = module.children.indexOf(dependency);
/******/                    if(idx >= 0) module.children.splice(idx, 1);
/******/                }
/******/            }
/******/        }
/******/    
/******/        // Not in "apply" phase
/******/        hotSetStatus("apply");
/******/    
/******/        hotCurrentHash = hotUpdateNewHash;
/******/    
/******/        // insert new code
/******/        for(var moduleId in appliedUpdate) {
/******/            if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
/******/                modules[moduleId] = appliedUpdate[moduleId];
/******/            }
/******/        }
/******/    
/******/        // call accept handlers
/******/        var error = null;
/******/        for(var moduleId in outdatedDependencies) {
/******/            if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
/******/                var module = installedModules[moduleId];
/******/                var moduleOutdatedDependencies = outdatedDependencies[moduleId];
/******/                var callbacks = [];
/******/                for(var i = 0; i < moduleOutdatedDependencies.length; i++) {
/******/                    var dependency = moduleOutdatedDependencies[i];
/******/                    var cb = module.hot._acceptedDependencies[dependency];
/******/                    if(callbacks.indexOf(cb) >= 0) continue;
/******/                    callbacks.push(cb);
/******/                }
/******/                for(var i = 0; i < callbacks.length; i++) {
/******/                    var cb = callbacks[i];
/******/                    try {
/******/                        cb(outdatedDependencies);
/******/                    } catch(err) {
/******/                        if(!error)
/******/                            error = err;
/******/                    }
/******/                }
/******/            }
/******/        }
/******/    
/******/        // Load self accepted modules
/******/        for(var i = 0; i < outdatedSelfAcceptedModules.length; i++) {
/******/            var item = outdatedSelfAcceptedModules[i];
/******/            var moduleId = item.module;
/******/            hotCurrentParents = [moduleId];
/******/            try {
/******/                __webpack_require__(moduleId);
/******/            } catch(err) {
/******/                if(typeof item.errorHandler === "function") {
/******/                    try {
/******/                        item.errorHandler(err);
/******/                    } catch(err) {
/******/                        if(!error)
/******/                            error = err;
/******/                    }
/******/                } else if(!error)
/******/                    error = err;
/******/            }
/******/        }
/******/    
/******/        // handle errors in accept handlers and self accepted module load
/******/        if(error) {
/******/            hotSetStatus("fail");
/******/            return callback(error);
/******/        }
/******/    
/******/        hotSetStatus("idle");
/******/        callback(null, outdatedModules);
/******/    }

/******/    // The module cache
/******/    var installedModules = {};

/******/    // The require function
/******/    function __webpack_require__(moduleId) {

/******/        // Check if module is in cache
/******/        if(installedModules[moduleId])
/******/            return installedModules[moduleId].exports;

/******/        // Create a new module (and put it into the cache)
/******/        var module = installedModules[moduleId] = {
/******/            exports: {},
/******/            id: moduleId,
/******/            loaded: false,
/******/            hot: hotCreateModule(moduleId),
/******/            parents: hotCurrentParents,
/******/            children: []
/******/        };

/******/        // Execute the module function
/******/        modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));

/******/        // Flag the module as loaded
/******/        module.loaded = true;

/******/        // Return the exports of the module
/******/        return module.exports;
/******/    }


/******/    // expose the modules object (__webpack_modules__)
/******/    __webpack_require__.m = modules;

/******/    // expose the module cache
/******/    __webpack_require__.c = installedModules;

/******/    // __webpack_public_path__
/******/    __webpack_require__.p = "";

/******/    // __webpack_hash__
/******/    __webpack_require__.h = function() { return hotCurrentHash; };

/******/    // Load entry module and return exports
/******/    return hotCreateRequire(0)(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

    /* WEBPACK VAR INJECTION */(function(console) {'use strict';

    var _request = __webpack_require__(2);

    var _request2 = _interopRequireDefault(_request);

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

    var cheerio = __webpack_require__(3);

    (0, _request2.default)('https://feedluna.wordpress.com/data/', function (error, response, html) {
        if (!error && response.statusCode == 200) {
            var $ = cheerio.load(html);

            var content = $('.entry-content').text();

            var returned = parsedata(content);

            console.log(returned);
        } else {
            console.log(error);
        }
    });

    function parsedata(data) {
        var buffer = '';
        var bufferlen = 0;
        var parsedData = [];
        var j = 0;

        for (var i = 0; i < data.length; i++) {
            buffer += data[i];
            bufferlen++;
            if (buffer[bufferlen - 1] == '\t' || buffer[bufferlen - 1] == '\n' || buffer[bufferlen - 1] == '\r') {
                if (bufferlen == 1) {
                    buffer = '';
                    bufferlen = 0;
                    continue;
                } else {
                    parsedData[j] = parseInt(buffer);
                    buffer = '';
                    bufferlen = 0;
                    j++;
                }
            }

            if (j == 2) {
                break;
            }
        }

        return parsedData;
    }
    /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))

/***/ },
/* 1 */
/***/ function(module, exports) {



/***/ },
/* 2 */
/***/ function(module, exports) {

    module.exports = request;

/***/ },
/* 3 */
/***/ function(module, exports) {

    module.exports = cheerio;

/***/ }
/******/ ]);

所以我查看了用于创建main.js的索引文件。我发现在node_modules文件夹中有一个请求的定义。以下是我点击它并告诉它去定义时发现的内容。


// Type definitions for request 2.48
// Project: https://github.com/request/request
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>,
//                 bonnici <https://github.com/bonnici>,
//                 Bart van der Schoor <https://github.com/Bartvds>,
//                 Joe Skeen <https://github.com/joeskeen>,
//                 Christopher Currens <https://github.com/ccurrens>,
//                 Jon Stevens <https://github.com/lookfirst>,
//                 Matt R. Wilson <https://github.com/mastermatt>
//                 Jose Colella <https://github.com/josecolella>
//                 Marek Urbanowicz <https://github.com/murbanowicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts

/// <reference types="node" />

import caseless = require('caseless');
import stream = require('stream');
import http = require('http');
import https = require('https');
import fs = require('fs');
import FormData = require('form-data');
import net = require('net');
import tough = require('tough-cookie');
import { Url } from 'url';
import { SecureContextOptions } from 'tls';

declare namespace request {
    interface RequestAPI<TRequest extends Request, TOptions extends CoreOptions, TUriUrlOptions> {
        defaults(options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>;
        defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;

        (uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        (uri: string, callback?: RequestCallback): TRequest;
        (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        get(uri: string, callback?: RequestCallback): TRequest;
        get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        post(uri: string, callback?: RequestCallback): TRequest;
        post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        put(uri: string, callback?: RequestCallback): TRequest;
        put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        head(uri: string, callback?: RequestCallback): TRequest;
        head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        patch(uri: string, callback?: RequestCallback): TRequest;
        patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        del(uri: string, callback?: RequestCallback): TRequest;
        del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        delete(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        delete(uri: string, callback?: RequestCallback): TRequest;
        delete(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;

        initParams(uri: string, options?: TOptions, callback?: RequestCallback): RequiredUriUrl & TOptions;
        initParams(uriOrOpts: string | RequiredUriUrl & TOptions, callback?: RequestCallback): RequiredUriUrl & TOptions;

        forever(agentOptions: any, optionsArg: any): TRequest;
        jar(store?: any): CookieJar;
        cookie(str: string): Cookie | undefined;

        debug: boolean;
    }

    interface DefaultUriUrlRequestApi<TRequest extends Request,
            TOptions extends CoreOptions,
            TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> {
        defaults(options: TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;
        (callback?: RequestCallback): TRequest;

        get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        get(uri: string, callback?: RequestCallback): TRequest;
        get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        get(callback?: RequestCallback): TRequest;

        post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        post(uri: string, callback?: RequestCallback): TRequest;
        post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        post(callback?: RequestCallback): TRequest;

        put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        put(uri: string, callback?: RequestCallback): TRequest;
        put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        put(callback?: RequestCallback): TRequest;

        head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        head(uri: string, callback?: RequestCallback): TRequest;
        head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        head(callback?: RequestCallback): TRequest;

        patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        patch(uri: string, callback?: RequestCallback): TRequest;
        patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        patch(callback?: RequestCallback): TRequest;

        del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        del(uri: string, callback?: RequestCallback): TRequest;
        del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        del(callback?: RequestCallback): TRequest;

        delete(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
        delete(uri: string, callback?: RequestCallback): TRequest;
        delete(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
        delete(callback?: RequestCallback): TRequest;
    }

    interface CoreOptions {
        baseUrl?: string;
        callback?: RequestCallback;
        jar?: CookieJar | boolean;
        formData?: { [key: string]: any };
        form?: { [key: string]: any } | string;
        auth?: AuthOptions;
        oauth?: OAuthOptions;
        aws?: AWSOptions;
        hawk?: HawkOptions;
        qs?: any;
        qsStringifyOptions?: any;
        qsParseOptions?: any;
        json?: any;
        jsonReviver?: (key: string, value: any) => any;
        jsonReplacer?: (key: string, value: any) => any;
        multipart?: RequestPart[] | Multipart;
        agent?: http.Agent | https.Agent;
        agentOptions?: http.AgentOptions | https.AgentOptions;
        agentClass?: any;
        forever?: any;
        host?: string;
        port?: number;
        method?: string;
        headers?: Headers;
        body?: any;
        family?: 4 | 6;
        followRedirect?: boolean | ((response: http.IncomingMessage) => boolean);
        followAllRedirects?: boolean;
        followOriginalHttpMethod?: boolean;
        maxRedirects?: number;
        removeRefererHeader?: boolean;
        encoding?: string | null;
        pool?: any;
        timeout?: number;
        localAddress?: string;
        proxy?: any;
        tunnel?: boolean;
        strictSSL?: boolean;
        rejectUnauthorized?: boolean;
        time?: boolean;
        gzip?: boolean;
        preambleCRLF?: boolean;
        postambleCRLF?: boolean;
        withCredentials?: boolean;
        key?: Buffer;
        cert?: Buffer;
        passphrase?: string;
        ca?: string | Buffer | string[] | Buffer[];
        har?: HttpArchiveRequest;
        useQuerystring?: boolean;
    }

    interface UriOptions {
        uri: string | Url;
    }
    interface UrlOptions {
        url: string | Url;
    }
    type RequiredUriUrl = UriOptions | UrlOptions;

    type OptionalUriUrl = RequiredUriUrl | {};

    type OptionsWithUri = UriOptions & CoreOptions;
    type OptionsWithUrl = UrlOptions & CoreOptions;
    type Options = OptionsWithUri | OptionsWithUrl;

    type RequestCallback = (error: any, response: Response, body: any) => void;

    interface HttpArchiveRequest {
        url?: string;
        method?: string;
        headers?: NameValuePair[];
        postData?: {
            mimeType?: string;
            params?: NameValuePair[];
        };
    }

    interface NameValuePair {
        name: string;
        value: string;
    }

    interface Multipart {
        chunked?: boolean;
        data?: Array<{
            'content-type'?: string,
            body: string
        }>;
    }

    interface RequestPart {
        headers?: Headers;
        body: any;
    }

    interface Request extends caseless.Httpified, stream.Stream {
        readable: boolean;
        writable: boolean;
        explicitMethod?: true;

        debug(...args: any[]): void;
        pipeDest(dest: any): void;
        qs(q: object, clobber?: boolean): Request;
        form(): FormData;
        form(form: any): Request;
        multipart(multipart: RequestPart[]): Request;
        json(val: any): Request;
        aws(opts: AWSOptions, now?: boolean): Request;
        hawk(opts: HawkOptions): void;
        auth(username: string, password: string, sendImmediately?: boolean, bearer?: string): Request;
        oauth(oauth: OAuthOptions): Request;
        jar(jar: CookieJar): Request;

        on(event: string, listener: (...args: any[]) => void): this;
        on(event: 'request', listener: (req: http.ClientRequest) => void): this;
        on(event: 'response', listener: (resp: Response) => void): this;
        on(event: 'data', listener: (data: Buffer | string) => void): this;
        on(event: 'error', listener: (e: Error) => void): this;
        on(event: 'complete', listener: (resp: Response, body?: string | Buffer) => void): this;
        on(event: 'pipe', listener: (src: stream.Readable) => void): this;
        on(event: 'socket', listener: (src: net.Socket) => void): this;

        write(buffer: Buffer | string, cb?: (err?: Error) => void): boolean;
        write(str: string, encoding?: string, cb?: (err?: Error) => void): boolean;
        end(cb?: () => void): void;
        end(chunk: string | Buffer, cb?: () => void): void;
        end(str: string, encoding?: string, cb?: () => void): void;

        pause(): void;
        resume(): void;
        abort(): void;
        destroy(): void;
        toJSON(): RequestAsJSON;

        // several of the CoreOptions are copied onto the request instance
        host?: string;
        port?: number;
        followAllRedirects?: boolean;
        followOriginalHttpMethod?: boolean;
        maxRedirects?: number;
        removeRefererHeader?: boolean;
        encoding?: string | null;
        timeout?: number;
        localAddress?: string;
        strictSSL?: boolean;
        rejectUnauthorized?: boolean;
        time?: boolean;
        gzip?: boolean;
        preambleCRLF?: boolean;
        postambleCRLF?: boolean;
        withCredentials?: boolean;
        key?: Buffer;
        cert?: Buffer;
        passphrase?: string;
        ca?: string | Buffer | string[] | Buffer[];
        har?: HttpArchiveRequest;

        // set in `Request.prototype.init`
        headers: Headers;
        method: string;
        pool: false | { [key: string]: http.Agent | https.Agent };
        dests: stream.Readable[];
        callback?: RequestCallback;
        uri: Url & { href: string, pathname: string };
        proxy: null | string | Url;
        tunnel: boolean;
        setHost: boolean;
        path: string;
        agent: false | http.Agent | https.Agent;
        body: Buffer | Buffer[] | string | string[] | stream.Readable;
        timing?: boolean;
        src?: stream.Readable;

        // set in `Request.prototype.start`
        href: string;
        startTime?: number;
        startTimeNow?: number;
        timings?: {
            socket: number;
            lookup: number;
            connect: number;
            response: number;
            end: number;
        };

        // set in `Request.prototype.onRequestResponse`
        elapsedTime?: number;
        response?: Response;
    }

    interface Response extends http.IncomingMessage {
        statusCode: number;
        statusMessage: string;
        request: Request;
        body: any; // Buffer, string, stream.Readable, or a plain object if `json` was truthy
        caseless: caseless.Caseless; // case-insensitive access to headers
        toJSON(): ResponseAsJSON;

        timingStart?: number;
        elapsedTime?: number;
        timings?: {
            socket: number;
            lookup: number;
            connect: number;
            response: number;
            end: number;
        };
        timingPhases?: {
            wait: number;
            dns: number;
            tcp: number;
            firstByte: number;
            download: number;
            total: number;
        };
    }

    // aliases for backwards compatibility
    type ResponseRequest = Request;
    type RequestResponse = Response;

    interface Headers {
        [key: string]: any;
    }

    interface AuthOptions {
        user?: string;
        username?: string;
        pass?: string;
        password?: string;
        sendImmediately?: boolean;
        bearer?: string | (() => string);
    }

    interface OAuthOptions {
        callback?: string;
        consumer_key?: string;
        consumer_secret?: string;
        token?: string;
        token_secret?: string;
        transport_method?: 'body' | 'header' | 'query';
        verifier?: string;
        body_hash?: true | string;
    }

    interface HawkOptions {
        credentials: any;
    }

    interface AWSOptions {
        secret: string;
        bucket?: string;
    }

    interface RequestAsJSON {
        uri: Url;
        method: string;
        headers: Headers;
    }

    interface ResponseAsJSON {
        statusCode: number;
        body: any;
        headers: Headers;
        request: RequestAsJSON;
    }

    type Cookie = tough.Cookie;

    interface CookieJar {
        setCookie(cookieOrStr: Cookie | string, uri: string | Url, options?: tough.CookieJar.SetCookieOptions): void;
        getCookieString(uri: string | Url): string;
        getCookies(uri: string | Url): Cookie[];
    }
}
declare var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>;
export = request;

当我在main.js或index.js中定义cheerio时,它会将我带到完全相同的位置。但是当我点击转到定义请求时,只有问题出现在main.js中它说没有找到定义。

我究竟做错了什么?

这是我的webpack.config.js文件。

 const path              = require('path');
const webpack           = require('webpack');
const htmlPlugin        = require('html-webpack-plugin');
const openBrowserPlugin = require('open-browser-webpack-plugin'); 
const dashboardPlugin   = require('webpack-dashboard/plugin');
const autoprefixer      = require('autoprefixer'); 

const PATHS = {
  app: path.join(__dirname, 'src'),
  images:path.join(__dirname,'src/assets/'),
  build: path.join(__dirname, 'dist')
};

const options = {
  host:'localhost',
  port:'1234'
};

module.exports = {
  entry: {
    app: PATHS.app
  },
  output: {
    path: PATHS.build,
    filename: 'main.js'
  },
  devServer: {
      historyApiFallback: true,
      hot: true,
      inline: true,
      stats: 'errors-only',
      host: options.host,
      port: options.port 
    },
  node: {
      console: 'empty',
      fs: 'empty',
      net: 'empty',
      tls: 'empty',
      cheerio: 'empty',
      request: 'empty'
    },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          cacheDirectory: true,
          presets: ['es2015']
        }
      },
      {
        test: /\.css$/,
        loaders: ['style', 'css', 'postcss'],
        include:PATHS.app
      },

      {
        test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,        
        loader: 'file',
        query: {
          name: '[path][name].[ext]'
        }
      },      
    ]
  },
  externals: ["fs","cheerio",'request'],
  postcss: function() {
    return [
      autoprefixer({
        browsers: [
          '>1%',
          'last 4 versions',
          'Firefox ESR',
          'not ie < 9',
        ]
      }),
    ];
  },
  plugins:[
    new dashboardPlugin(),
    new webpack.HotModuleReplacementPlugin({
        multiStep: true
    }),
    new htmlPlugin({
      template:path.join(PATHS.app,'index.html'),
      inject:'body'
    }),
    new openBrowserPlugin({
      url: `http://${options.host}:${options.port}`
    })
  ]
};
javascript webpack
1个回答
0
投票

你把请求放在externals section。这意味着webpack假设请求包含在其他位置,因此它不会将其包含在您的包中。从外部采取请求应解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.