suitcss / suit

Style tools for UI components
http://suitcss.github.io/
3.8k stars 225 forks source link

Webpack #159

Open raulghm opened 7 years ago

raulghm commented 7 years ago

What is the best way for work with webpack?

simonsmith commented 7 years ago

For now I'd recommend using the postcss-loader and add the plugins you need. So something like:

// postcss.loader.js
const atImport = require('postcss-import');
const customProperties = require('postcss-custom-properties');
const customMedia = require('postcss-custom-media');
const autoPrefixer = require('autoprefixer');

module.exports = {
  loader: 'postcss-loader',
  options: {
    plugins() {
      return [
        atImport,
        customProperties,
        customMedia,
        autoPrefixer,
      ];
    },
  },
};
// webpack.config.js
const postcssLoader = require('./postcss.loader');

module.exports = {
 /* ... other config options */
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader?importLoaders=1',
          postcssLoader,
        ],
      },
    ],
  },
});

We'll look into a more 'official' solution if it makes sense, otherwise I'll just get this documented. Let's leave this issue open until then

shavidzet commented 7 years ago

I had same problem, I wanted to use suitcss preprocessor and utils as a webpack plugin, that's why I decide to develop following plugin https://github.com/ShavidzeT/suit-webpack-plugin

simonsmith commented 7 years ago

@ShavidzeT Nice. We certainly need a more concise solution.

I had actually started work on a webpack plugin for SUIT too. I'll add it to the org when I get a chance to finish it.

mlnmln commented 5 years ago

I would recommend just to document how to use SUIT with postcss loader.

Other than that, see https://github.com/suitcss/suit/issues/162