Skip to content

Commit

Permalink
Upgrade plugin for use with svg.js v3
Browse files Browse the repository at this point in the history
- es6 module
- normalized constructors
- added rollup build chain
- remove bower
  • Loading branch information
Fuzzyma committed Dec 21, 2018
1 parent effdd60 commit 559d4e2
Show file tree
Hide file tree
Showing 13 changed files with 4,942 additions and 881 deletions.
86 changes: 86 additions & 0 deletions .config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import babel from 'rollup-plugin-babel'
import * as pkg from '../package.json'
import filesize from 'rollup-plugin-filesize'
// import { terser } from 'rollup-plugin-terser'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import { uglify } from 'rollup-plugin-uglify'

const buildDate = Date()

const headerLong = `/*!
* ${pkg.name} - ${pkg.description}
* @version ${pkg.version}
* ${pkg.homepage}
*
* @copyright ${pkg.author.name}
* @license ${pkg.license}
*
* BUILT: ${buildDate}
*/;`

const headerShort = `/*! ${pkg.name} v${pkg.version} ${pkg.license}*/;`

const getBabelConfig = (targets, corejs = false) => babel({
include: 'src/**',
runtimeHelpers: true,
babelrc: false,
presets: [['@babel/preset-env', {
modules: false,
targets: targets || pkg.browserslist,
//useBuiltIns: 'usage'
}]],
plugins: [['@babel/plugin-transform-runtime', {
corejs: corejs,
helpers: true,
useESModules: true
}]]
})

// When few of these get mangled nothing works anymore
// We loose literally nothing by let these unmangled
const classes = [

]

const config = (node, min) => ({
external: ['@svgdotjs/svg.js'],
input: 'src/svg.filter.js',
output: {
file: node ? './dist/svg.filter.node.js'
: min ? './dist/svg.filter.min.js'
: './dist/svg.filter.js',
format: node ? 'cjs' : 'iife',
name: 'SVG.Filter',
sourcemap: true,
banner: headerLong,
// remove Object.freeze
freeze: false,
globals: {
'@svgdotjs/svg.js': 'SVG',
},
},
treeshake: {
// property getter have no sideeffects
propertyReadSideEffects: false
},
plugins: [
resolve(),
commonjs(),
getBabelConfig(node && 'maintained node versions'),
filesize(),
!min ? {} : uglify({
mangle: {
reserved: classes
},
output: {
preamble: headerShort
}
})
]
})

// [node, minified]
const modes = [[false], [false, true], [true]]

export default modes.map(m => config(...m))
9 changes: 9 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

extends: standard
rules:
operator-linebreak: [ error, before ]
object-curly-spacing: [ error, always ]
indent: [ error, 2, {
flatTernaryExpressions: true
}]
padded-blocks: off
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
examples.html
translation.js
node_modules
node_modules
dist
49 changes: 0 additions & 49 deletions Gruntfile.js

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Fuzzy
Copyright (c) 2018 Wout Fierens

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
Loading

0 comments on commit 559d4e2

Please sign in to comment.