Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ FEATURE ] setEntries() method #1113

Open
gzhegow1991 opened this issue Apr 26, 2022 · 5 comments
Open

[ FEATURE ] setEntries() method #1113

gzhegow1991 opened this issue Apr 26, 2022 · 5 comments

Comments

@gzhegow1991
Copy link

gzhegow1991 commented Apr 26, 2022

Always i've wroten setter i must create delete or clear method.

That should be solved via creating methods: setItems() + addItem()

Its a minimum. If you pass setItems([]) - it work like "delete". Then you add "addItems", "deleteItem", "deleteItems" if needed or skip that useless stuff.

Why "set" is needed?
We see "Google Pagespeed" recommendation about "separate bundles for ES5 and ES2015+" - almost 50% filesize difference.

We need to create two bundles with two configs.

But ConfigValidator forbid you to .getWebpackConfig() without entries. You add "app" as entry, and next you need to create "app.es5" entry, but inside the list already "app". You cant delete it.

===

Also bug:

    .configureFilenames( {
        // js entries
        js: isEnabledVersioning
            ? 'js/[name].[contenthash].js'
            : 'js/[name].js',

        // css imports
        css: isEnabledVersioning
            ? 'css/[name].[contenthash].css'
            : 'css/[name].css',

        // imported images and fonts, possible url-loader background: url() things
        assets: isEnabledVersioning
            ? 'assets/[ext]/[name].[hash][ext]'
            : 'assets/[ext]/[name][ext]',
    } )

AND

        .configureImageRule( {
            enabled: true,

            type   : 'asset/resource', // asset, asset/resource, asset/inline
            maxSize: 0,

            filename: isEnabledVersioning
                ? 'img/[name].[hash][ext]'
                : 'img/[name][ext]',
        } )

There's no way to define:

const config = Encore.getWebpackConfig();

// js dynamic imports (await import('file.js'))
config.output.chunkFilename = isEnabledVersioning ? 'js/chunk/[name].[contenthash].js' : 'js/chunk/[name].js';
@stof
Copy link
Member

stof commented Apr 26, 2022

if you need to create 2 configs, that's what the Encore.reset() is for.

@gzhegow1991
Copy link
Author

gzhegow1991 commented Apr 26, 2022

thats what am talking about.

  1. what about that encore wants to clear output directory starting building from second config?
    yes, we define something like:
    .cleanupOutputBeforeBuild( [ '!**/*' ] )
  1. also encore cant rename 'entrypoints.json', seems it should be two different build folders, otherwise config from one encore could change output of second one
    .configureManifestPlugin( (options) => {
        options.filename = 'manifest.json'; // can rename manifest. cant rename entrypoints. cant merge entrypoints. cant force symfony to use different entrypoints. cant twig get second entrypoints from symfony.
    } )

Moral? Think first.

@stof
Copy link
Member

stof commented Apr 27, 2022

@6562680 the solution to me is to use separate output folders for your modern and legacy builds: public/build and public/legacy-build for instance. This way, you won't have file name conflicts

@gzhegow1991
Copy link
Author

gzhegow1991 commented Apr 27, 2022

Yes, did it, actually build contains images and other shared things.
Even if repository ignores any builds at least one required points - using "php encore code" to select from one manifest or two manifest, one entrypoints.json or second.

I had done it myself with raw php without symfony, cus of no twig extension, no symfony config for that, thank god am writing on raw php with those "recommendations" like "its fine, dont worry, get out"

Actually the problem is "create method "set" for sibling "add" - europeans again recommend to find "solution"... That brain is broken. 100th time that shit. They never think standart. They think like "solve here"

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants