question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The entry names between addEntry() and addStyleEntry() must be unique.

See original GitHub issue

Hi, I just moved to v0.14 and wanted to use the new Encore.configureFilenames() method you added, here is the config I used:

Encore
    .setOutputPath('web/assets/')
    .setPublicPath('/assets')
    .cleanupOutputBeforeBuild()
    .configureFilenames({
        css: 'css/[name]-[contenthash].css',
        js: 'js/[name]-[chunkhash].js'
    })

    .addEntry('admin', './app/Resources/assets/js/admin.js')
    .addEntry('main', './app/Resources/assets/js/main.js')

    .addStyleEntry('admin', './app/Resources/assets/scss/admin.scss')
    .addStyleEntry('main', './app/Resources/assets/scss/main.scss')
...

I thought it wouldn’t be a problem since JS and CSS files are compiled in different directories (the objective being to have a web/assets/js/admin.js and a web/assets/css/admin.css files), but I had this error:

Error: The "admin" passed to addStyleEntry() conflicts with a name passed to addEntry(). The entry names between addEntry() and addStyleEntry() must be unique.

Just wondering if that’s really causing a problem to have the same name, it’s not a really big problem to change it, I just found that weird!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Lyrkancommented, Sep 5, 2017

Another way to solve that is to avoid calling addStyleEntry and directly require CSS files from JS files.

For instance:

// webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('build/')
    .setPublicPath('/')
    .cleanupOutputBeforeBuild()
    .configureFilenames({
        css: 'css/[name]-[contenthash].css',
        js: 'js/[name]-[chunkhash].js'
    })
    .enableVersioning()
    .enableSassLoader()
    .addEntry('main', './src/main.js')
    .addEntry('admin', './src/admin.js')
;

module.exports = Encore.getWebpackConfig()
// src/main.js
require('./main.scss')

// (...)
// src/admin.js
require('./admin.scss')

// (...)

2017-09-05_13-45-41

0reactions
Lyrkancommented, Feb 6, 2018

@Sydney-o9 I don’t think there is something about it in the Symfony docs, but you can refer to the index.js file to see how to use it:

https://github.com/symfony/webpack-encore/blob/2684b7a907ed1351e5cd9439011cb811802af428/index.js#L680-L701

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate name "app" passed to addEntry(): entries must be ...
The error message is clear Duplicate name "app" passed to addEntry(): entries must be unique.
Read more >
Encore: Setting up your Project (Symfony Docs)
The key part is addEntry() : this tells Encore to load the assets/app.js file and follow all of the require() statements. It will...
Read more >
Page-Specific JS: Multiple Entries > Webpack Encore
This contains some traditional JavaScript from a previous tutorial. ... Next, go into webpack.config.js and, up here, call addEntry() again. Name it ...
Read more >
How to use the @symfony/webpack-encore.addEntry function ...
enableSassLoader() // allow sass/scss files to be processed .enableSourceMaps(!Encore.isProduction()) .cleanupOutputBeforeBuild() // empty the outputPath ...
Read more >
First steps - Ibexa Developer Documentation
addStyleEntry() method) to your own Encore configuration for your project ... Input the Content Type's name, for example "Blog Post", and identifier: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found