-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zhivka Dimova <zhivka.dimova@myforest.net>
- Loading branch information
Showing
2 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import {rollup} from 'rollup'; | ||
import serve from 'rollup-plugin-serve'; | ||
|
||
import buble from '@rollup/plugin-buble'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import terser from '@rollup/plugin-terser'; | ||
|
||
import pkg from './package.json' assert { type: 'json' }; | ||
|
||
let stringify = function({ | ||
importeePrefix = 'stringify!', | ||
plugins = [], | ||
} = {}) { | ||
let ids = new Set(); | ||
return { | ||
name: 'stringify', | ||
async resolveId(importee, importer) { | ||
if (importee.startsWith(importeePrefix)) { | ||
importee = importee.slice(importeePrefix.length); | ||
let {id} = await this.resolve(importee, importer); | ||
ids.add(id); | ||
return id; | ||
} | ||
return null; | ||
}, | ||
async load(id) { | ||
if (ids.has(id)) { | ||
let bundle = await rollup({ | ||
input: id, | ||
plugins, | ||
}); | ||
let {output} = await bundle.generate({format: 'iife'}); | ||
let [{code}] = output; | ||
return `export default ${JSON.stringify(code)}`; | ||
} | ||
return null; | ||
}, | ||
}; | ||
}; | ||
|
||
let plugins = [ | ||
stringify({ | ||
plugins: [ | ||
buble(), | ||
terser(), | ||
], | ||
}), | ||
resolve(), | ||
buble({objectAssign: 'Object.assign'}), | ||
terser({mangle: {properties: {regex: /^ǂ/}}}), | ||
]; | ||
|
||
if (process.env.ROLLUP_WATCH) { | ||
plugins.push(serve({ | ||
contentBase: '', | ||
open: true, | ||
})); | ||
} | ||
|
||
let globals = { | ||
'vue': 'Vue', | ||
}; | ||
|
||
export default { | ||
external: Object.keys(Object.assign(pkg.devDependencies, pkg.peerDependencies)), | ||
input: 'src/index.js', | ||
plugins: plugins, | ||
output: { | ||
file: pkg.main, | ||
format: 'umd', | ||
name: 'VueWordCloud', | ||
globals, | ||
}, | ||
}; |