Skip to content

Instantly share code, notes, and snippets.

View pyrsmk's full-sized avatar
🤖
boop. boop. boop beep boop.

Aurélien Delogu pyrsmk

🤖
boop. boop. boop beep boop.
View GitHub Profile
@pyrsmk
pyrsmk / build.js
Last active June 13, 2019 11:41
Systèmes de build : vanilla JS
const { CLIEngine } = require('eslint')
const rollup = require('rollup')
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
const uglify = require('uglify-js')
const fs = require('fs')
const chalk = require('chalk')
const info = message => {
console.info(chalk.yellow(' * ') + chalk.green(message))
@pyrsmk
pyrsmk / package.json
Last active June 10, 2019 16:29
Systèmes de build : scripts NPM
{
"scripts": {
"build": "yarn lint && yarn bundle && yarn minify && yarn minify-dev",
"lint": "eslint 'src/**'",
"bundle": "rollup -c",
"minify": "uglifyjs dist/toast.js -o dist/toast.min.js",
"minify-dev": "uglifyjs dist/toast.js -o tests/lib/toast.min.js --source-map filename=toast.js,url=inline && rm tests/lib/toast.min.js.map",
}
}
@pyrsmk
pyrsmk / just-task.js
Last active June 13, 2019 11:38
Systèmes de build : Just
const { task, series, logger } = require('just-task')
const { CLIEngine } = require('eslint')
const rollup = require('rollup')
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
const uglify = require('uglify-js')
const fs = require('fs')
const lint = options => {
const eslint = new CLIEngine()
@pyrsmk
pyrsmk / gulpfile.js
Last active June 13, 2019 11:37
Systèmes de build : Gulp
const { src, dest, series } = require('gulp')
const eslint = require('gulp-eslint')
const rollup = require('gulp-better-rollup')
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
const ts = require('gulp-typescript')
const sourcemaps = require('gulp-sourcemaps')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
@pyrsmk
pyrsmk / Gruntfile.js
Last active June 13, 2019 11:37
Systèmes de build : Grunt
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
module.exports = grunt => {
grunt.loadNpmTasks('grunt-eslint')
grunt.loadNpmTasks('grunt-rollup')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.initConfig({
eslint: {
@pyrsmk
pyrsmk / taskfile.js
Created June 13, 2019 12:12
Systèmes de build : taskr
const { CLIEngine } = require('eslint')
const rollup = require('rollup')
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
exports.lint = function* () {
yield new Promise((resolve, reject) => {
const eslint = new CLIEngine()
const formatter = eslint.getFormatter()
const { results } = eslint.executeOnFiles(['src/**'])
@pyrsmk
pyrsmk / rollup.js
Created July 23, 2019 14:01
Rollup task for Just
const rollup = require('rollup')
const typescript = require('rollup-plugin-typescript2')
const prepack = require('rollup-plugin-prepack-up')
module.exports = async options => {
await rollup.rollup({
input: options.input,
plugins: [
typescript({ useTsconfigDeclarationDir: true }),
prepack(),
@pyrsmk
pyrsmk / eslint.js
Created July 23, 2019 14:02
Eslint task for Just
const { CLIEngine } = require('eslint')
const { logger } = require('just-task')
module.exports = options => {
const eslint = new CLIEngine()
const formatter = eslint.getFormatter()
const { results } = eslint.executeOnFiles([options.glob])
if (results.reduce((value, item) => value + item.errorCount, 0)) {
logger.info(formatter(results))
throw new Error('Linter has found errors')
@pyrsmk
pyrsmk / uglify.js
Created July 23, 2019 14:02
Uglify task for Just
const uglify = require('uglify-js')
const fs = require('fs')
module.exports = async options => {
const params = {}
if ('sourcemap' in options && 'filename' in options) {
params.sourceMap = {
filename: options.filename,
url: 'inline',
}
@pyrsmk
pyrsmk / just-task.js
Created July 23, 2019 15:57
Just task example with source()
task('bundle', () => {
source('src/MyLib.ts').rollup({
format: 'umd',
name: 'mylib',
plugins: [
typescript(),
prepack(),
],
}).tofile('dist/mylib.js')
}))