I try to complete this tutorial, but I have some trouble with configure webpack i think. I was making tutorial step by step but it doesn't work..
ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.10.3:webpack (webpack build) on project shop: Failed to run task: 'webpack.js ' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2
error looks like:
[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-35 webpack.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"] } }] } ] } }; app.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'))