Field 'browser' doesn't contain a valid alias configuration

后端 未结 16 2306
无人共我
无人共我 2020-12-01 11:54

I\'ve started using webpack2 (to be precise, v2.3.2) and after re-creating my config I keep running into an issue I can\'t seem to solve I get (sorry in advance

16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 12:04

    I'm building a React server-side renderer and found this can also occur when building a separate server config from scratch. If you're seeing this error, try the following:

    1. Make sure your "entry" value is properly pathed relative to your "context" value. Mine was missing the preceeding "./" before the entry file name.
    2. Make sure you have your "resolve" value included. Your imports on anything in node_modules will default to looking in your "context" folder, otherwise.

    Example:

    const serverConfig = {
    name: 'server',
    context: path.join(__dirname, 'src'),
    entry: {serverEntry: ['./server-entry.js']},
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'server.js',
        publicPath: 'public/',
        libraryTarget: 'commonjs2'
    },
    module: {
        rules: [/*...*/]
    },
    resolveLoader: {
        modules: [
            path.join(__dirname, 'node_modules')
        ]
    },
    resolve: {
        modules: [
            path.join(__dirname, 'node_modules')
        ]
    }
    };
    

提交回复
热议问题