Skip to content

chore(css): css preprocessors support enhancement #1492

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

Closed
wants to merge 1 commit into from

Conversation

jkuri
Copy link
Contributor

@jkuri jkuri commented Jul 29, 2016

This addon allows "global" CSS extension language files in public/ dir which are then merged to dist/app.css and that file can be included in index.html.

This webpack build runs concurrently with the main build compilation.

},
output: {
path: path.resolve(projectRoot, './dist'),
filename: '[name].css'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hash in output filename, hash will be required in prod build

@sirajc
Copy link

sirajc commented Jul 29, 2016

@jkuri CSS/SASS files are part of source for project and it would be good if we have that under src folder, something like src/assets

@Meligy
Copy link
Contributor

Meligy commented Jul 29, 2016

+1 to @sirajc for not using public. I think, as per the ember-cli convention, the public folder should have no processors other than copying aso-is into the root of the website.

@clydin
Copy link
Member

clydin commented Jul 30, 2016

Instead of a fixed location, how about a configuration setting for global styles? Ideally the option would accept an array of files with glob support. This allows public, as well as src/assets, or just an individual file. It could also allow pulling in styles directly from a package as well.

Where to put the option is the question. Does it fit in angular-cli.json? Or would it be better to add a separate config file for project specific build options?

@jkuri
Copy link
Contributor Author

jkuri commented Jul 30, 2016

I'll update this in the next hours, but it is not quite sure this will be merged.

@filipesilva
Copy link
Contributor

filipesilva commented Aug 1, 2016

We talked a bit more about this functionality, and this is the current plan:

  • add the following property to config
{
   // ...
  "apps": [
    {
     // ...
      styles: {
        "src/style.css": { output: "style.css", autoImported: true }
      }
    }
  ],
  • add file on sourceDir, maybe with a comment about css imports if the styleExt for the project is css
  • add entry point on wepack config common using config to resolve
  • add test that checks that global styles are included (see test for sass/etc for code you can copy paste)

@intellix
Copy link
Contributor

intellix commented Aug 1, 2016

We have component-name.css so why not index.css next to index.html?

from: path.resolve(projectRoot, './public'),
to: path.resolve(projectRoot, './dist'),
ignore: ['**/*.sass', '**/*.scss', '**/*.styl', '**/*.less']
}])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkuri public directory should be copied as is, in full. styles should be part of src

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, reverted.

@jkuri jkuri force-pushed the css-preprocessors branch 2 times, most recently from 991c913 to ecf8d51 Compare August 1, 2016 10:12
@jkuri
Copy link
Contributor Author

jkuri commented Aug 1, 2016

@intellix you could change that in angular-cli.json, I'll write a documentation about it. Btw, just pushed to this.

@intellix
Copy link
Contributor

intellix commented Aug 1, 2016

shouldn't the file be: addon/ng2/blueprints/ng2/files/__path__/style.__styleext__ to support pre-processors as well?

@jkuri jkuri force-pushed the css-preprocessors branch from ecf8d51 to fb84d85 Compare August 1, 2016 14:40
@jkuri
Copy link
Contributor Author

jkuri commented Aug 1, 2016

yes, thanks, was a long night.

@jkuri jkuri force-pushed the css-preprocessors branch 3 times, most recently from 1c42b72 to dba8714 Compare August 1, 2016 15:39
@sirajc
Copy link

sirajc commented Aug 1, 2016

Great work @jkuri, Thanks..., with this we can define styles like

"apps": [
    {
      "main": "src/main.ts",
      "tsconfig": "src/tsconfig.json",
      "mobile": false,
      "styles": [
            "assets/vendor/paper.bootstrap.css",
            "styles/index.scss"
      ]
    }
  ]

👍

@jkuri
Copy link
Contributor Author

jkuri commented Aug 1, 2016

@sirajc no problem. I still have some minor improvements to do with injecting styles and write tests but this, I think, would be it. Actually the config looks like:

"styles": {
  "src/style.css": { "output": "style.css", "autoImported": true },
  "src/app.sass": { "output": "app.css", "autoImported": true }
}

but this will be noted in the readme for sure. In the meanwhile feel free to test this and report any bugs. Thanks.

@jkuri jkuri force-pushed the css-preprocessors branch 5 times, most recently from 52ffe5b to 9536ae5 Compare August 2, 2016 03:09
@jkuri jkuri force-pushed the css-preprocessors branch 3 times, most recently from c25fdd2 to 3862874 Compare August 2, 2016 20:26
@jkuri
Copy link
Contributor Author

jkuri commented Aug 2, 2016

I managed to get mobile tests passing and working with app-shell prerender.
@filipesilva, @TheLarkInn please review.

@@ -60,10 +60,6 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
},
plugins: [
new ForkCheckerPlugin(),
new HtmlWebpackPlugin({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a custom plugin for that which injects .css files configured with autoImported: true into index.html. In this plugin we have also configuration for mobile support which generates content automactically (app-shell).

@jkuri
Copy link
Contributor Author

jkuri commented Aug 3, 2016

this PR does not follow the proper design so I am closing it.

@jkuri jkuri closed this Aug 3, 2016
@sirajc
Copy link

sirajc commented Aug 4, 2016

@jkuri Should we discuss the design on #1459

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants