windicss / windicss-webpack-plugin

🍃 Windi CSS for webpack ⚡
https://windicss.org/integrations/webpack.html
79 stars 19 forks source link

feat: support devtools for better user experience #110

Closed await-ovo closed 2 years ago

await-ovo commented 2 years ago

Feature Request

@harlan-zw Hi, first of all, it's nice to be able to use this plugin inside webpack, but it would be nice to be able to use design in devtools like vite.

I really like design in devtools and autocomplete, it is awesome!

So, I've tried to add a backend server to handle post requests from devtools. So far it's working ok in examples:

next-webpack-wini-devtools

Just import "windi-devtools" or "virtual:windi-devtools" into your code and you can experience this very cool feature.

I also added a server user option to customize the host and port of the backend server, like following:

module.exports = {
  webpack: {
    plugins: {
      add: [
        new WindiCSSWebpackPlugin({
          virtualModulePath: 'src',
          server: {
            port: 9999,
            host: 'localhost'
          }
        })
      ],
    },
  }
}

Known Issues

// craco.config.js
module.exports = {
  eslint: {
      pluginOptions: config => {
        config.exclude = ['**/node_modules/**', '**/virtual:windi-devtools*']
        return config;
      },
  }
}

Finally, thank you very much for reading the content of this PR and the review :)

harlan-zw commented 2 years ago

This is really awesome, great job and thanks for the contribution :clap: @await-ovo!