Skip to content

Commit a0028c6

Browse files
committed
copy setup from scroll-into-view-if-needed
1 parent f92c482 commit a0028c6

File tree

8 files changed

+704
-0
lines changed

8 files changed

+704
-0
lines changed

.babelrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const BABEL_ENV = process.env.BABEL_ENV
2+
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs'
3+
4+
const plugins = []
5+
6+
if (process.env.NODE_ENV === 'production') {
7+
plugins.push('dev-expression')
8+
}
9+
10+
if (BABEL_ENV === 'cjs') {
11+
plugins.push('babel-plugin-add-module-exports')
12+
}
13+
14+
module.exports = {
15+
comments: false,
16+
presets: [
17+
'@babel/preset-typescript',
18+
[
19+
'@babel/preset-env',
20+
{
21+
loose: true,
22+
modules: building ? false : 'commonjs',
23+
},
24+
],
25+
],
26+
plugins: plugins,
27+
}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,13 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
63+
# Typescript stuff
64+
typings
65+
src/*.js
66+
67+
lerna-debug.log
68+
dist
69+
es
70+
umd
71+
/index.js

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package.json

package.json

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"name": "compute-scroll-into-view",
3+
"description": "The engine that powers scroll-into-view-if-needed",
4+
"license": "MIT",
5+
"author": "Stian Didriksen",
6+
"homepage": "https://scroll-into-view-if-needed.netlify.com",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/stipsan/compute-scroll-into-view.git"
10+
},
11+
"version": "1.0.0",
12+
"main": "index.js",
13+
"module": "es/index.js",
14+
"files": [
15+
"es",
16+
"typings",
17+
"umd"
18+
],
19+
"scripts": {
20+
"prebuild": "yarn clean",
21+
"build": "yarn build:d.ts && yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd.min",
22+
"build:cjs": "BABEL_ENV=cjs babel src -d . --extensions '.ts'",
23+
"build:d.ts": "tsc --emitDeclarationOnly",
24+
"build:es": "BABEL_ENV=es babel src -d es --extensions '.ts'",
25+
"build:umd": "BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/compute-scroll-into-view.js",
26+
"build:umd.min": "BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/compute-scroll-into-view.min.js",
27+
"clean": "rimraf 'umd' 'es' 'typings'",
28+
"precommit": "lint-staged",
29+
"dev": "concurrently 'tsc --noEmit --watch' 'yarn build:cjs --watch' 'yarn build:es --watch' 'yarn build:umd --watch' 'yarn build:umd.min --watch'",
30+
"prepublishOnly": "unset npm_config_cafile && yarn build",
31+
"typecheck": "tsc --noEmit"
32+
},
33+
"devDependencies": {
34+
"@babel/cli": "7.0.0-beta.51",
35+
"@babel/core": "7.0.0-beta.51",
36+
"@babel/plugin-external-helpers": "7.0.0-beta.51",
37+
"@babel/preset-env": "7.0.0-beta.51",
38+
"@babel/preset-typescript": "7.0.0-beta.51",
39+
"babel-eslint": "8.2.5",
40+
"babel-plugin-add-module-exports": "0.2.1",
41+
"babel-plugin-dev-expression": "0.2.1",
42+
"concurrently": "3.6.0",
43+
"eslint": "4.19.1",
44+
"eslint-config-prettier": "2.9.0",
45+
"eslint-plugin-import": "2.13.0",
46+
"eslint-plugin-react": "7.10.0",
47+
"flowgen": "1.2.2",
48+
"husky": "0.14.3",
49+
"lint-staged": "7.2.0",
50+
"prettier": "1.13.6",
51+
"prettier-package-json": "1.6.0",
52+
"rimraf": "2.6.2",
53+
"rollup": "0.61.2",
54+
"rollup-plugin-babel": "4.0.0-beta.5",
55+
"rollup-plugin-commonjs": "9.1.3",
56+
"rollup-plugin-node-resolve": "3.3.0",
57+
"rollup-plugin-replace": "2.0.0",
58+
"rollup-plugin-terser": "1.0.1",
59+
"semantic-release": "15.6.0",
60+
"tslint": "5.10.0",
61+
"tslint-config-prettier": "1.13.0",
62+
"typescript": "2.9.2"
63+
},
64+
"keywords": [
65+
"scroll",
66+
"if-needed",
67+
"scroll-into-view",
68+
"scroll-into-view-if-needed",
69+
"scrollIntoView",
70+
"scrollIntoViewIfNeeded",
71+
"scrollMode",
72+
"typescript"
73+
],
74+
"browserify": {
75+
"transform": [
76+
"loose-envify"
77+
]
78+
},
79+
"bundlesize": [
80+
{
81+
"path": "./umd/compute-scroll-into-view.min.js",
82+
"maxSize": "1.75 kB"
83+
},
84+
{
85+
"path": "./umd/compute-scroll-into-view.js",
86+
"maxSize": "3 kB"
87+
}
88+
],
89+
"lint-staged": {
90+
"*.js": [
91+
"prettier --write",
92+
"git add"
93+
],
94+
"*.{ts,tsx}": [
95+
"prettier --write",
96+
"git add"
97+
],
98+
"*.json": [
99+
"prettier --write",
100+
"git add"
101+
],
102+
"*.md": [
103+
"prettier --write",
104+
"git add"
105+
],
106+
"**/package.json": [
107+
"prettier-package-json --write",
108+
"git add"
109+
],
110+
"**/.babelrc": [
111+
"prettier --write",
112+
"git add"
113+
]
114+
},
115+
"prettier": {
116+
"semi": false,
117+
"singleQuote": true,
118+
"trailingComma": "es5",
119+
"overrides": [
120+
{
121+
"files": ".babelrc",
122+
"options": {
123+
"parser": "json"
124+
}
125+
}
126+
]
127+
},
128+
"release": {
129+
"prepare": [
130+
"@semantic-release/npm"
131+
]
132+
},
133+
"sideEffects": false,
134+
"typings": "typings/index.d.ts"
135+
}

rollup.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import babel from 'rollup-plugin-babel'
2+
import commonjs from 'rollup-plugin-commonjs'
3+
import resolve from 'rollup-plugin-node-resolve'
4+
import replace from 'rollup-plugin-replace'
5+
import { terser } from 'rollup-plugin-terser'
6+
7+
const config = {
8+
input: 'src/index.ts',
9+
output: {
10+
name: 'computeScrollIntoView',
11+
},
12+
plugins: [
13+
babel({
14+
exclude: 'node_modules/**',
15+
}),
16+
resolve({
17+
extensions: ['.ts', '.js', '.json'],
18+
}),
19+
commonjs({
20+
include: /node_modules/,
21+
}),
22+
replace({
23+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
24+
}),
25+
],
26+
}
27+
28+
if (process.env.NODE_ENV === 'production') {
29+
config.plugins.push(terser())
30+
}
31+
32+
export default config

0 commit comments

Comments
 (0)