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

[chore] Configure WebPack #9

Open
tinacious opened this issue Sep 26, 2024 · 0 comments
Open

[chore] Configure WebPack #9

tinacious opened this issue Sep 26, 2024 · 0 comments
Labels
priority: 2 (low) Low priority

Comments

@tinacious
Copy link
Owner

tinacious commented Sep 26, 2024

Figma plugins are not bootstrapped with bundling by default, they just transpile every single TypeScript file individually. This works if your plugin has no UI since you just need a code.ts file. It doesn't work too well if you have UI and want to maintain some level of code organization.

They do provide instructions for configuring WebPack: https://www.figma.com/plugin-docs/libraries-and-bundling/#setup-typescript-with-webpack

There's also a WebPack React example: https://github.com/figma/plugin-samples/tree/master/webpack-react – Can we quickly adapt this to use Vue so as to limit the refactoring we need to do? We can probably use the plugins config used here to support inlining the TypeScript code as JS in the ui.html file.

  plugins: [
    new webpack.DefinePlugin({
      global: {}, // Fix missing symbol error when running in developer VM
    }),
    new HtmlWebpackPlugin({
      inject: 'body',
      template: './src/ui.html',
      filename: 'ui.html',
      chunks: ['ui'],
    }),
    new HtmlInlineScriptPlugin({
      htmlMatchPattern: [/ui.html/],
      scriptMatchPattern: [/.js$/],
    }),

Let's bundle the dependencies instead of using <script src="" /> tags to CDN resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: 2 (low) Low priority
Projects
None yet
Development

No branches or pull requests

1 participant