Open
Description
Hi everyone
I'm using symfony 7 with encore.
i dont know what i'm doing wrong here. i always get the following error in my Dev-Tools-Console:
Uncaught TypeError: Failed to resolve module specifier "@symfony/stimulus-bridge". Relative references must start with either "/", "./", or "../".
this is my webpack config:
const Encore = require("@symfony/webpack-encore");
const path = require("path");
// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || "dev");
}
Encore
// directory where compiled assets will be stored
.setOutputPath("public/build/")
// public path used by the web server to access the output path
.setPublicPath("/build")
// only needed for CDN's or subdirectory deploy
//.setManifestKeyPrefix('build/')
/*
* ENTRY CONFIG
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge("./assets/controllers.json")
// will require an extra script tag for runtime.js
// but, you probably want this, unless you're building a single-page app
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// enables and configure @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = "usage";
config.corejs = "3.23";
})
// enables Sass/SCSS support
//.enableSassLoader()
// uncomment if you use TypeScript
.addEntry("app", "./assets/main.ts")
.enableTypeScriptLoader()
.enablePostCssLoader()
.configureDevServerOptions((options) => {
options.allowedHosts = "all"; // allows connections from any host
(options.headers = {
"Access-Control-Allow-Origin": "*", // allow any origin
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers":
"X-Requested-With, content-type, Authorization",
}),
(options.liveReload = true);
options.static = {
watch: false,
};
options.watchFiles = {
paths: ["src/**/*.php", "templates/**/*"],
};
});
module.exports = Encore.getWebpackConfig();
my assets/controllers.json file:
{
"controllers": {},
"entrypoints": []
}
main.ts:
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import "./styles/app.css";
import "./bootstrap.ts";
import "./ts/dataTables.ts";
import { startStimulusApp } from "@symfony/stimulus-bridge";
export const app = startStimulusApp(
require.context(
"../node_modules/@symfony/stimulus-bridge/lazy-controller-loader!./controllers",
true,
/\.(j|t)sx?$/
)
);
I cannot get rid of the error. Has anyone had this issue as well?
Thanks for your help!
Metadata
Assignees
Labels
No labels