this.data = require("/static/content/" + this.place + "/main.json")esto es trabajo
this.path = "/static/content/" + this.place this.data = require(this.path + "/main.json")Esto es malo.
El error se ve así:
Uncaught Error: Cannot find module '/static/content/Suzanne/main.json' at webpackEmptyContext (.json$:2:1) at EExplore.init (EExplore.js:9:21) at new EExplore (EExplore.js:3:1) at Module.1213 (explore.js:5:1) at __webpack_require__ (bootstrap:24:1) at __webpack_exec__ (explore.js:39:1) at explore.js:39:1 at Function.__webpack_require__.O (chunk loaded:23:1) at explore.js:39:1 at webpackJsonpCallback (jsonp chunk loading:521:1)Estoy realmente confundido.
¿Hay alguna diferencia entre estas dos formas?
El archivo de configuración de mi paquete web está aquí si lo necesita
devServer: { watchFiles: ["src/**", "static/**"], static: { watch: true, directory: path.join(__dirname, "./static"), }, }, plugins: [ ... new CopyWebpackPlugin({ patterns: [ { from: path.resolve(__dirname, "./static"), to: "static/", }, ], }),