Set up build and linting

pull/1/head
Nikita Karamov 2020-03-25 17:44:11 +01:00
parent 293bea2f93
commit b00532af4c
No known key found for this signature in database
GPG Key ID: E40DFE6E993540FF
11 changed files with 3146 additions and 7 deletions

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
dist

6
.eslintrc.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
extends: ['airbnb-typescript/base'],
parserOptions: {
project: './tsconfig.json',
},
};

2
.gitignore vendored
View File

@ -1 +1,3 @@
dev
dist
node_modules

9
.travis.yml Normal file
View File

@ -0,0 +1,9 @@
language: node_js
node_js:
- node
- lts/erbium
- lts/dubnium
cache: yarn
install: yarn
script: yarn test

View File

@ -10,7 +10,6 @@
"url": "https://github.com/NickKaramoff/shareon/issues"
},
"license": "MIT",
"author": "Nikita Karamov <nick@karamoff.dev>",
"description": "Lightweight, stylish and ethical share buttons for popular social networks",
"keywords": [
@ -18,12 +17,26 @@
"sharing",
"social networks"
],
"main": "./dist/shareon.js",
"scripts": {},
"scripts": {
"build": "rollup -c ./rollup/rollup.config.prod.js",
"dev": "rollup -w -c ./rollup/rollup.config.dev.js",
"pretest": "run-p build",
"test:lint": "eslint --ext .js,.ts ./src/",
"test": "run-p test:*"
},
"dependencies": {},
"devDependencies": {}
"devDependencies": {
"@rollup/plugin-strip": "^1.3.2",
"@rollup/plugin-typescript": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-typescript": "^7.2.0",
"eslint-plugin-import": "^2.20.1",
"np": "^6.2.0",
"npm-run-all": "^4.1.5",
"rollup": "^2.2.0",
"rollup-plugin-terser": "^5.3.0",
"typescript": "^3.8.3"
}
}

19
rollup/plugins.js Normal file
View File

@ -0,0 +1,19 @@
import rollupPluginStrip from '@rollup/plugin-strip';
import { terser as rollupPluginTerser } from 'rollup-plugin-terser';
import rollupPluginTypescript from '@rollup/plugin-typescript';
export const strip = () => rollupPluginStrip({
debugger: true,
functions: ['console.log', 'console.debug'],
sourceMap: false,
});
export const terser = () => rollupPluginTerser({
sourcemap: false,
output: {
comments: false,
ecma: 5,
},
});
export const typescript = () => rollupPluginTypescript();

View File

@ -0,0 +1,18 @@
import { typescript } from './plugins';
const input = './src/index.ts';
const name = 'shareon';
const outputDir = './dev/';
export default {
input,
output: {
name,
format: 'iife',
file: `${outputDir}${name}.js`,
},
plugins: [
typescript(),
],
};

View File

@ -0,0 +1,32 @@
import { strip, terser, typescript } from './plugins';
const input = './src/index.ts';
const name = 'shareon';
const outputDir = './dist/';
export default {
input,
output: [
{
name,
format: 'esm',
file: `${outputDir}${name}.mjs`,
},
{
name,
format: 'cjs',
file: `${outputDir}${name}.cjs`,
},
{
name,
format: 'iife',
file: `${outputDir}${name}.min.js`,
plugins: [terser()],
},
],
plugins: [
typescript(),
strip(),
],
};

0
src/index.ts Normal file
View File

18
tsconfig.json Normal file
View File

@ -0,0 +1,18 @@
{
"compilerOptions": {
"lib": [
"dom",
"es6"
],
"module": "ES2020",
"noImplicitAny": true,
"noImplicitReturns": true,
"target": "es5"
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules"
]
}

3021
yarn.lock

File diff suppressed because it is too large Load Diff