Giter VIP home page Giter VIP logo

Comments (5)

Aziz403 avatar Aziz403 commented on July 20, 2024 1

Hello !

First of all, I am very proud and happy to talk to you.
It's only been 6 months since I started Symfony through your lessons on Symfonycasts.

In datatables.net we have many datatables themes , and i want to give the developer the possiblity to choices the theme easy by passe the name of theme to the Datatable object.
to use the object later in TwigExtension to render the datatable and import the theme in the same time.

The current solution is like what you said :

What is the condition? It is likely that you will need 2 different controllers for the 2 different situations. And the user chooses which to use somehow.

separate the themes using empty controllers by import the theme js & css file inside .

I don't know if it's the best pratique ?

from webpack-encore-bundle.

Aziz403 avatar Aziz403 commented on July 20, 2024 1

Thanks for your time !
Unfortunately, the themes is contians JS & CSS files.
so i think in this is situation we have one solution :

separate the themes using empty controllers by import the theme js & css file inside .

from webpack-encore-bundle.

weaverryan avatar weaverryan commented on July 20, 2024

Hi!

Do you still have this issue? I know what bundle you're referring to now :).

maybe that impossible because webpack needs to build files before

Yes, Webpack needs to know all of the files at build time - that part can't change at runtime.

i need to import js file with this is view, the js file can changed base on condition.

What is the condition? It is likely that you will need 2 different controllers for the 2 different situations. And the user chooses which to use somehow.

Cheers!

from webpack-encore-bundle.

weaverryan avatar weaverryan commented on July 20, 2024

Thanks for your kind words ❤️ . And congrats for coming so far in just 6 months!

In datatables.net we have many datatables themes , and i want to give the developer the possiblity to choices the theme easy by passe the name of theme to the Datatable object

Unfortunately, while this makes sense from a user perspective, Webpack needs to know "at build time" which CSS files to include. So, this config needs to live in some file that Webpack parses - e.g. controllers.json. There's not going to be a great way to handle this in Symfony config or when the user renders the data table.

If changing from one theme to another is only a matter of using one CSS file vs another CSS file, then the best way to handle this is using autoimport in controllers.json. I'd recommend shipping with one CSS file enabled by default, then maybe a few other CSS files in autoimport for other themes, which are disabled by default. Example: https://github.com/symfony/ux/blob/b7f636b1c22cc8dd8bcf3a7785bff96e8eb5b64c/src/Autocomplete/assets/package.json#L15-L18

Cheers!

from webpack-encore-bundle.

weaverryan avatar weaverryan commented on July 20, 2024

I agree - cheers!

from webpack-encore-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.