我認(rèn)為配置 webpack 時(shí)遇到了一些問題。我正在一步步制作教程,但它不起作用。錯(cuò)誤] 無法在項(xiàng)目商店上執(zhí)行目標(biāo) com.github.eirslett:frontend-maven-plugin:1.10.3:webpack (webpack build):無法運(yùn)行任務(wù):“webpack.js”失敗。org.apache.commons.exec.ExecuteException:進(jìn)程退出并出現(xiàn)錯(cuò)誤:2錯(cuò)誤看起來像:[INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve './client' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]? @ ./src/main/js/app.js 29:13-32[INFO]?[INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve 'react' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]? @ ./src/main/js/app.js 25:12-28[INFO]?[INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve 'react-dom' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]? @ ./src/main/js/app.js 27:15-35webpack.config.js:var path = require('path');module.exports = {? ? entry: './src/main/js/app.js',? ? devtool: 'sourcemaps',? ? cache: true,? ? mode: 'development',? ? output: {? ? ? ? path: __dirname,? ? ? ? filename: './src/main/resources/static/built/bundle.js'? ? },? ? module: {? ? ? ? rules: [? ? ? ? ? ? {? ? ? ? ? ? ? ? test: path.join(__dirname, '.'),? ? ? ? ? ? ? ? exclude: /(node_modules)/,? ? ? ? ? ? ? ? use: [{? ? ? ? ? ? ? ? ? ? loader: 'babel-loader',? ? ? ? ? ? ? ? ? ? options: {? ? ? ? ? ? ? ? ? ? ? ? presets: ["@babel/preset-env", "@babel/preset-react"]? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? }]? ? ? ? ? ? }? ? ? ? ]? ? }};應(yīng)用程序.js:'use strict';const React = require('react');const ReactDOM = require('react-dom');const client = require('./client');class App extends React.Component {...}class EmployeeList extends React.Component{...}class Employee extends React.Component{...}ReactDOM.render(<App/>, document.getElementById('react'))
如何正確配置webpack?
慕森王
2023-08-10 15:42:09