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

Add Angular Support #9

Open
benjaminforras opened this issue Mar 18, 2021 · 2 comments
Open

Add Angular Support #9

benjaminforras opened this issue Mar 18, 2021 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@benjaminforras
Copy link

Can someone show me an example when this plugin is being used with Angular & Webpack?

@harlan-zw
Copy link
Member

harlan-zw commented Mar 22, 2021

Hey @TryHardDood

I have tried it with angular but it has an interesting webpack setup which I haven't been able to figure out.

This is as far as I got https://github.com/windicss/windicss-webpack-plugin/blob/feat/angular-example/example/angular/webpack.config.js. It seems like it doesn't pull in the virtual windi file, so will only transform @apply's in css atm.

If you have any experience with it would love a hand.

@harlan-zw harlan-zw added the help wanted Extra attention is needed label Mar 22, 2021
@harlan-zw harlan-zw changed the title An example for Angular with Webpack? Add Angular Support Feb 1, 2022
@jsanta
Copy link

jsanta commented Feb 16, 2022

Hi.
As far as I've seen the problem is not on how Angular makes its compilation, but on how Webpack is getting the styles.
I've made the following tests:

  1. created an Angular project
  2. installed windi-webpack plugin
  3. added import 'windi.css'; to the main.ts file
  4. installed @angular-builders/custom-webpack
  5. created a webpack-windi.config.js file using the example
  6. changed the angular,json file so the architect.build.builder section looks like:
"architect": {
        "build": {
          "builder": "@angular-builders/custom-webpack:browser",
          "outputs": ["{options.outputPath}"],
          "options": {
            "customWebpackConfig": {
              "path": "./webpack-windi.config.js",
              "mergeRules": {
                "externals": "replace"
              }
            },

and the serve.builder section like:

"serve": {
          "builder": "@angular-builders/custom-webpack:dev-server",
  1. run the angular project using ng serve
  2. inspected the main.js bundle file <- here, there's a definition for all windi styles

So after this I tried to see what was inside this virtual file. For that I used the val-loader webpack plugin, and got the complete windi styles (without cleaning all unused styles).

I'm stuck trying to generate the CSS style file from this virtual file.
Hope my findings help at least a bit, we are willing to drop Tailwind in favor of faster build times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants