@webdevandsausages/mailing-list-widget

A widget for joining the Web Dev & Sausages mailing list

Usage no npm install needed!

<script type="module">
  import webdevandsausagesMailingListWidget from 'https://cdn.skypack.dev/@webdevandsausages/mailing-list-widget';
</script>

README

@webdevandsauages/mailing-list-widget

This is component is intended for use in webdevandsausages.org and is not suitable for other projects. The original boilerplate is from svelte component template.

Table of Contents

  1. Getting started
  2. Developing
  3. Consuming components
  4. Backward Compatibility
  5. Preprocessors

Getting Started usin the component

npm i @webdevandsauages/mailing-list-widget --save

Include in your project

<script>
    import {JoinMailingList} from '@webdevandsausages/event-terminal'
</script>

<div>
    {#if process.browser}
        <JoinMailingList />
    {/if}
</div>

Developing

  1. Start Rollup:
npm run dev
  1. Edit a component file in src/components, save it, and reload the page to see your changes.

  2. Make sure your component is exported in src/components/components.module.js.

  3. Make sure your component is imported and nested in src/App.svelte.

  4. Navigate to localhost:3000 to see your components live.

  5. In development the express dev server will proxy /api requests tolocalhost:5000

Consuming Components

Your package.json has a "svelte" field pointing to src/components/components.module.js, which allows Svelte apps to import the source code directly, if they are using a bundler plugin like rollup-plugin-svelte or svelte-loader (where resolve.mainFields in your webpack config includes "svelte"). This is recommended.

For everyone else, npm run build will bundle your component's source code into a plain JavaScript module (index.mjs) and a UMD script (index.js), in the dist folder.
This will happen automatically when you publish your component to npm, courtesy of the prepublishOnly hook in package.json.

Backward Compatibility

This template uses svelte-preprocess in order to integrate PostCSS auto-prefixing capabilities into the build process.

Browserlist

PostCSS uses browserlist under the hood, in order to "know" what css to prefix.

The browserlist configuration is located inside the package.json.

Preprocessors

This template comes with the svelte-preprocess by default, which simplifies the use of preprocessors in components.

Usage

  1. Install the required preprocessors.
  2. Enable the preprocessor in the component.