Coder Social home page Coder Social logo

devtron-next's Introduction

Svelte Tailwind Extension Boilerplate

You can use this boilerplate code to start developing a Chrome extension using either JavaScript or TypeScript, Svelte for the frontend, Tailwind CSS for styling, Jest for testing, and Rollup as the build system.

This boilerplate also comes with automatic reloading during development with the help of rollup-plugin-chrome-extension. No more constantly refreshing the page to see your changes!

Get Started

Using degit

Type this into your terminal:

npx degit "kyrelldixon/svelte-tailwind-extension-boilerplate#main" your-extension-name
yarn

Using the Github template

Github templates allow you to create a copy of a repo to build your own project with. Click Use this template at the top of the page to get your own copy.

Development

For development with automatic reloading:

yarn dev

Open the Extensions Dashboard, enable "Developer mode", click "Load unpacked", and choose the dist folder.

Production

When it's time to publish to Chrome, make a production build. Run the following line:

yarn build

This will create a ZIP file with your package name and version in the releases folder.

Using TypeScript

This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:

node scripts/setupTypeScript.js

Or remove the script via:

rm scripts/setupTypeScript.js

Source Layout

Your manifest is at src/manifest.json, and Rollup will bundle any files you include here. All the filepaths in your manifest should point to files in src.

src
├── background
│   └── index.js
├── content
│   └── index.js
├── manifest.json
└── popup
    ├── Counter.svelte
    ├── Counter.test.js
    ├── Popup.svelte
    ├── index.html
    ├── index.js
    └── tailwind.css
  • Popup.svelte will become the extension's "browser action" popup
  • popup/index.js tells Popup where to load in index.html. It is also where Tailwind CSS gets loaded
  • tailwind.css is where you will add any custom tailwind styles

Why these choices?

I wanted a boilerplate that would make it as easy as possible to get started building features and not setting up configurations. I also wanted the best possible extension development experience using modern tooling.

  • TypeScript: TypeScript saves you from ambiguous bugs and makes it the code super easy to navigate through. I made it optional so that you have the freedom to opt into TypeScript's extra functionality when you want to.
  • Tailwind CSS: This is my favorite CSS library because it helps me move fast. It's offers the perfect balance of speed and flexibility.
  • Svelte: Svelte helps keep the bundle size small through it's compilation step, and makes the code easy to navigate. It's a newer framework, but I think it is perfect for small focused applications like browser extensions
  • Jest: A clean framework that comes with everything you need for mocking, testing DOM interactions, and making sure your app is delivering the features you expect it to.
  • Rollup: Rollup takes advantage of ES Modules which keeps your bundle sizes small and optimized. It is also much easier to read and update than Webpack.

Acknowledgments

Special thanks to Jack and Amy at extend-chrome for making rollup-plugin-chrome-extension. Check out their repos if you're really looking to make developing extensions and easier and more enjoyable experience.

Other repos that helped me build the boilerplate:

devtron-next's People

Contributors

daihy8759 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.