Skip to content

Commit

Permalink
feat(build): Use Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
Donskelle committed Apr 28, 2020
1 parent 78ce0aa commit 55ef78f
Show file tree
Hide file tree
Showing 21 changed files with 4,333 additions and 2,577 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
},
{
"files": ["demo/**"],
"files": ["public/**"],
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ dist
.tern-port

# in progress
dev/
docs/
6 changes: 3 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.github
docs
demo
dev
dist
public
config
.eslintrc
.eslintignore
.size-limit.json
prettier.config.js
rollup.config.js
netlify.toml
jest.config.js
es-dev-server.config.js
7 changes: 0 additions & 7 deletions es-dev-server.config.js

This file was deleted.

6,805 changes: 4,259 additions & 2,546 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"description": "git packages test",
"module": "src/index.js",
"scripts": {
"start": "npx es-dev-server",
"size": "npx size-limit",
"start": "npx http-server dist",
"build": "rollup -c",
"size": "size-limit",
"size-build": "echo 'no build'",
"lint": "npx eslint src",
"lint:fix": "npx prettier --write src && npx eslint --fix src",
"release": "npx release-it",
"test": "npx jest"
"lint": "eslint src",
"lint:fix": "prettier --write src && eslint --fix src",
"release": "release-it",
"test": "jest"
},
"repository": {
"type": "git",
Expand All @@ -26,6 +27,8 @@
},
"homepage": "https://github.com/Donskelle/pwa-helpers#readme",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@release-it/conventional-changelog": "^1.1.2",
"@size-limit/preset-big-lib": "^4.4.5",
"auto-changelog": "^2.0.0",
Expand All @@ -38,7 +41,12 @@
"lint-staged": "^10.1.6",
"prettier": "^2.0.4",
"release-it": "^13.5.4",
"service-worker-mock": "^2.0.5",
"rollup": "^2.7.3",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-cpy": "^2.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-workbox": "^5.0.1",
"size-limit": "^4.4.5"
},
"release-it": {
Expand Down Expand Up @@ -68,5 +76,8 @@
"npx prettier --write",
"npx eslint --fix"
]
},
"dependencies": {
"@babel/plugin-transform-runtime": "^7.9.0"
}
}
2 changes: 1 addition & 1 deletion demo/createUiPrompt.js → public/createUiPrompt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { idleFramePromise } from 'https://unpkg.com/@donskelle/pwa-helpers/src/index.js?module';
import { idleFramePromise } from './index.js';
/**
* Create beautiful ui prompt
* @param {String} content
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
14 changes: 8 additions & 6 deletions demo/index.html → public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
navigator.serviceWorker.register('./sw.js');
}
</script>
<script type="module">
import './pwa-install.js';
</script>
</head>
<body>
<h3>Menu</h3>
<nav>
<h3>Menu</h3>
<ul>
<li>Home</li>
<li>About</li>
Expand Down Expand Up @@ -70,10 +67,15 @@ <h3>Content</h3>
<hr />
<footer>
<h3>Footer</h3>
<pwa-install-button><button>Install</button></pwa-install-button>
<pwa-install-button>
<button>Install</button>
</pwa-install-button>
</footer>
<script type="module">
import { setupInstallListener } from 'https://unpkg.com/@donskelle/pwa-helpers/src/index.js?module';
import './pwa-install.js';
</script>
<script type="module">
import { setupInstallListener } from './index.js';

setupInstallListener();
</script>
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions demo/pwa-install.js → public/pwa-install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
addInstallAvailableObserver,
removeInstallAvailableObserver,
} from 'https://unpkg.com/@donskelle/pwa-helpers/src/index.js?module';
import { addInstallAvailableObserver, removeInstallAvailableObserver } from './index.js';
import { createUiPrompt } from './createUiPrompt.js';

// Github's way to handle instance state thats not related to attributes / properties.
Expand Down
2 changes: 1 addition & 1 deletion demo/style.css → public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ body {
transform: scale(1, 1);
opacity: 1;
}
}
}
File renamed without changes.
41 changes: 41 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import copy from 'rollup-plugin-copy';

// const { generateSW } = require("rollup-plugin-workbox");

export default {
input: './src/index.js',
output: {
file: './dist/index.js',
format: 'esm',
name: 'bundle',
},
plugins: [
babel({
// babelrc: false,
// runtimeHelpers: true,
presets: [
[
'@babel/preset-env',
{
corejs: 3,
modules: false,
useBuiltIns: 'usage',
targets: {
chrome: 81,
edge: 81,
firefox: 75,
safari: 12,
},
},
],
],
}),
resolve(),
copy({
targets: [{ src: 'public/**/*', dest: 'dist' }],
flatten: false,
}),
],
};

0 comments on commit 55ef78f

Please sign in to comment.