PolymerX / polymer-skeleton

:skull: Skeleton for Polymer 3 app with Webpack, PostCSS and Service Workers ready.
https://polymer-skeleton.herokuapp.com
MIT License
177 stars 23 forks source link

Add postcss and remove node-sass #2

Closed LasaleFamine closed 7 years ago

LasaleFamine commented 7 years ago

Need to implement the postcss-loader with webpack during development and also for the production build.

equinusocio commented 7 years ago

We also need to enable this PostCSS plugin (included) to incapsulate CSS:

We can also consider to add these plugins as a "starter kit":

LasaleFamine commented 7 years ago

Useful: posthtml-postcss

equinusocio commented 7 years ago

Absolutely!

equinusocio commented 7 years ago

PostHTML Loader

LasaleFamine commented 7 years ago

Give a try: feature/postcss

  $ yarn dev:postcss

And start playing with the webpack-app.usable.html component. Could be a solution? Currently only the autoprefixer plugin is loaded, but we can add other plugins easily.

If it's good, I think we can create a simple loader for Webpack (the PostHTML Loader seems not work), remove the .usable.html file and work directly on the main HTML file. 🚀

LasaleFamine commented 7 years ago

Changed files, now we have:

Of course we need to avoid the .style file during development as we can load everything with Webpack. Need some changes to achieve this.

equinusocio commented 7 years ago

I can suggest a naming convention:

Since style-module.html will be generated on build time, during development will we have only:

What do you think? style-module is the official name of this kind of file. Check the Polymer Doc

LasaleFamine commented 7 years ago

Looks great!

LasaleFamine commented 7 years ago

Of course we need to avoid the .style file during development as we can load everything with Webpack. Need some changes to achieve this.

I think we simply can't.
I tried some configurations with Wepback but there is no way to just load the compiled file in memory and read it from the component HTML file, since we are obligated to require the CSS within the es6.js to be able to show it to Webpack file and this is not good, because the best thing we can do is to encapsulate the CSS within the JS (and after within the body) and not the component itself.

What do you think if we maintain the four files with the names you proposed? I pushed some changes, if you will run yarn dev it will watch both .es6.js and .style.html files and of course turn on a web server.
yarn dev:style (the old yarn dev:postcss) and yarn dev:js (the old yarn dev) are still present.

We can think about further development in the future.

equinusocio commented 7 years ago

we can have this? (a pure .postcss file) I think this is better than an .html file with css inside, if we can..

LasaleFamine commented 7 years ago

Oh yep, this could be a solution: compiling the postcss and inject it within the style-module. Will work on this ASAP.

equinusocio commented 7 years ago

I think is better have a webpack-app.postcss file rather than an "un-named" style.postcss.

This could be an example of component structure

style-module.html

<dom-module id='webpack-app-style'>
  <template>
    <style>
      /* inject point */
    </style>
  </template>
</dom-module>

webpack-app.html

<!-- Import the component css module-->
<link rel='import' href='style-module.html'>

<dom-module is='webpack-app'>
  <template>

    <!-- CSS inclusion point -->
    <style include='webpack-app-style'>
         /* ...additional CSS */
    </style>

    <content></content>

  </template>
</dom-module>