Skip to content

Commit cd796aa

Browse files
committed
initial commit
0 parents  commit cd796aa

File tree

8 files changed

+758
-0
lines changed

8 files changed

+758
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
node_modules
3+
/dist/

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*Psst — looking for an app template? Go here --> [sveltejs/template](https://github.com/sveltejs/template)*
2+
3+
---
4+
5+
# component-template
6+
7+
A base for building shareable Svelte components. Clone it with [degit](https://github.com/Rich-Harris/degit):
8+
9+
```bash
10+
npx degit sveltejs/component-template my-new-component
11+
cd my-new-component
12+
npm install # or yarn
13+
```
14+
15+
Your component's source code lives in `src/Component.svelte`.
16+
17+
You can create a package that exports multiple components by adding them to the `src` directory and editing `src/index.js` to reexport them as named exports.
18+
19+
TODO
20+
21+
* [ ] some firm opinions about the best way to test components
22+
* [ ] update `degit` so that it automates some of the setup work
23+
24+
25+
## Setting up
26+
27+
* Run `npm init` (or `yarn init`)
28+
* Replace this README with your own
29+
30+
31+
## Consuming components
32+
33+
Your package.json has a `"svelte"` field pointing to `src/index.js`, which allows Svelte apps to import the source code directly, if they are using a bundler plugin like [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) or [svelte-loader](https://github.com/sveltejs/svelte-loader) (where [`resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolve-mainfields) in your webpack config includes `"svelte"`). **This is recommended.**
34+
35+
For everyone else, `npm run build` will bundle your component's source code into a plain JavaScript module (`dist/index.mjs`) and a UMD script (`dist/index.js`). This will happen automatically when you publish your component to npm, courtesy of the `prepublishOnly` hook in package.json.

package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "svelte-range-slider-pips",
3+
"svelte": "src/index.js",
4+
"module": "dist/index.mjs",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "rollup -c",
8+
"prepublishOnly": "npm run build"
9+
},
10+
"devDependencies": {
11+
"@rollup/plugin-node-resolve": "^6.0.0",
12+
"rollup": "^1.20.0",
13+
"rollup-plugin-svelte": "^5.0.0",
14+
"svelte": "^3.0.0"
15+
},
16+
"keywords": [
17+
"svelte"
18+
],
19+
"files": [
20+
"src",
21+
"dist"
22+
],
23+
"version": "0.9.0",
24+
"description": "Multi-Thumb, Accessible, Beautiful Range Slider with Pips",
25+
"repository": "x",
26+
"author": "Simon Goellner <[email protected]>",
27+
"license": "MIT",
28+
"private": false
29+
}

rollup.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import svelte from 'rollup-plugin-svelte';
2+
import resolve from '@rollup/plugin-node-resolve';
3+
import pkg from './package.json';
4+
5+
const name = pkg.name
6+
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
7+
.replace(/^\w/, m => m.toUpperCase())
8+
.replace(/-\w/g, m => m[1].toUpperCase());
9+
10+
export default {
11+
input: 'src/index.js',
12+
output: [
13+
{ file: pkg.module, 'format': 'es' },
14+
{ file: pkg.main, 'format': 'umd', name }
15+
],
16+
plugins: [
17+
svelte(),
18+
resolve()
19+
]
20+
};

0 commit comments

Comments
 (0)