简体   繁体   中英

Webpack configuration problem with module.exports entry

I'm trying to configurate webpack but I stuck because of this error. I think the problem is with entry. But when i try to add it without path: like in tutorial i get "(property) path: path.PlatformPath" ',' expected

 const webpack = require('webpack')
    const path = require('path');
    
    const CopyWebpackPlugin = require('copy-webpack-plugin')
    const MiniCssExtractPlugin = require('mini-css-extract-plugin')
    
    const IS_DEVELOPMENT = process.env.NODE_ENV === 'dev'
    
    const dirApp = path.join(__dirname, 'app')
    const dirAssets = path.join(__dirname, 'assets')
    const dirStyles = path.join(__dirname, 'styles')
    const dirNode = 'node_modules'
    
    module.exports = {
        entry: {
           path: path.join(dirApp, 'index.js'),
           path: path.join(dirStyles, 'index.scss'),
        },
    
        resolve: {
            modules: {
                dirApp,
                dirAssets,
                dirStyles,
                dirNode
            }
        }
    }

I get this error

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.resolve.modules should be an array:
   object { alias?, aliasFields?, byDependency?, cache?, cachePredicate?, cacheWithContext?, conditionNames?, descriptionFiles?, enforceExtension?, exportsFields?, extensionAlias?, extensions?, 
fallback?, fileSystem?, fullySpecified?, importsFields?, mainFields?, mainFiles?, modules?, plugins?, preferAbsolute?, preferRelative?, resolver?, restrictions?, roots?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
   -> Folder names or directory paths where to find modules.

Your resolve.modules is Object, but should be Array. Check here for docs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM