From c43c7e2170918e5a5b2337326ce0804997422e4c Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Wed, 25 Mar 2020 19:09:56 +0100 Subject: [PATCH] Add banner --- package.json | 1 + rollup/plugins.js | 8 +++++++- rollup/rollup.config.prod.js | 5 +++-- yarn.lock | 27 +++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a3c54f9..c944b8d 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "np": "^6.2.0", "npm-run-all": "^4.1.5", "rollup": "^1.32.1", + "rollup-plugin-banner": "^0.2.1", "rollup-plugin-postcss": "^2.5.0", "rollup-plugin-terser": "^5.3.0", "typescript": "^3.8.3" diff --git a/rollup/plugins.js b/rollup/plugins.js index 8278168..3201211 100644 --- a/rollup/plugins.js +++ b/rollup/plugins.js @@ -1,9 +1,14 @@ import postcssPluginCssnano from 'cssnano'; +import rollupPluginBanner from 'rollup-plugin-banner'; import rollupPluginPostcss from 'rollup-plugin-postcss'; import rollupPluginStrip from '@rollup/plugin-strip'; import { terser as rollupPluginTerser } from 'rollup-plugin-terser'; import rollupPluginTypescript from '@rollup/plugin-typescript'; +export const banner = () => rollupPluginBanner( + '<%= pkg.name %> v<%= pkg.version %> by Nikita Karamov\nInspired by Likely (https://ilyabirman.net/projects/likely/)' +) + export const postcss = (file, minify) => rollupPluginPostcss({ extract: file || true, plugins: [ @@ -15,7 +20,8 @@ export const postcss = (file, minify) => rollupPluginPostcss({ export const strip = () => rollupPluginStrip({ debugger: true, - functions: ['console.log', 'console.debug'], + include: ['**/*.js', '**/*.ts'], + functions: ['console.log', 'console.debug', 'assert.*'], sourceMap: false, }); diff --git a/rollup/rollup.config.prod.js b/rollup/rollup.config.prod.js index 9324b1b..158e2d3 100644 --- a/rollup/rollup.config.prod.js +++ b/rollup/rollup.config.prod.js @@ -1,4 +1,4 @@ -import { postcss, strip, terser, typescript } from './plugins'; +import { banner, postcss, strip, terser, typescript } from './plugins'; const input = './src/index.ts'; const name = 'shareon'; @@ -27,7 +27,8 @@ export default { ], plugins: [ typescript(), - postcss(`${outputDir}${name}.css`, true), strip(), + postcss(`${outputDir}${name}.css`, true), + banner() ], }; diff --git a/yarn.lock b/yarn.lock index 9901a48..b445228 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2436,6 +2436,11 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +lodash._reinterpolate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= + lodash.camelcase@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" @@ -2446,6 +2451,21 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +lodash.template@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" + integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.templatesettings "^4.0.0" + +lodash.templatesettings@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" + integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -3970,6 +3990,13 @@ rimraf@2.6.3: dependencies: glob "^7.1.3" +rollup-plugin-banner@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-banner/-/rollup-plugin-banner-0.2.1.tgz#f62f26c468530ecea16263da83175079625f9c6f" + integrity sha512-Bs1uIPCsGpKIkNOwmBsCqn+dJ/xaojWk9PNlvd+1MEScddr1yUQlO6McAXi72wJyNWYL+9u9EI2JAZMpLRH92w== + dependencies: + lodash.template "^4.4.0" + rollup-plugin-postcss@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/rollup-plugin-postcss/-/rollup-plugin-postcss-2.5.0.tgz#54ef2487cda498d8bca69aaca3b55b30dee0106b"