Skip to content

Commit

Permalink
[Chore] Added javascript sourcemaps support which required replacing …
Browse files Browse the repository at this point in the history
…`rollup-plugin-banner` with `rollup-plugin-banner2` which does supports sourcemaps. Also fixed the banner comment which seems to have not been correct for a long time
  • Loading branch information
yairEO committed Feb 11, 2024
1 parent d8f74bb commit ef50d7e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
20 changes: 14 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ var gulp = require('gulp'),
'sass': 'xsass' // map to some other name because 'gulp-sass' already loads "sass", so avoid collusion
} }),
terser = require("rollup-plugin-terser").terser,
rollupBanner = require("rollup-plugin-banner").default,
rollupBanner = require("rollup-plugin-banner2"),
babel = require("@rollup/plugin-babel").babel,
fs = require('fs'),
buffer = require('vinyl-buffer'),
rollupStream = require("@rollup/stream"),
pkg = require('./package.json'),
sass = require('gulp-sass')(require('sass')),
Expand All @@ -19,10 +20,14 @@ const LICENSE = fs.readFileSync("./LICENSE", "utf8");

var rollupCache = {};

var banner = `Tagify (v ${process.env.npm_package_version}) - tags input component
By ${pkg.author.name}
var banner = `/*
Tagify v${process.env.npm_package_version} - tags input component
By: ${pkg.author}
${pkg.homepage}
${LICENSE}`;
${LICENSE}
*/
`;

var jQueryPluginWrap = [`;(function($){
// just a jQuery wrapper for the vanilla version of this component
Expand Down Expand Up @@ -143,14 +148,14 @@ function rollup({ entry, outputName, dest, plugins=[], babelConf={}, format='umd
...plugins
]

plugins.push( rollupBanner(banner) )
plugins.push( rollupBanner(() => banner) )

return rollupStream({
input: entry,
plugins,
// sourcemap: true,
cache: rollupCache[entry],
output: {
sourcemap: true,
name: 'Tagify',
format: format,
}
Expand All @@ -161,7 +166,10 @@ function rollup({ entry, outputName, dest, plugins=[], babelConf={}, format='umd

// give the file the name you want to output with
.pipe( $.vinylSourceStream(outputName))
.pipe(buffer())
// .on('error', handleError)
.pipe($.sourcemaps.init({ loadMaps: true }))
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
"gulp-watch": "^5.0.1",
"path": "^0.12.7",
"rollup": "^2.75.5",
"rollup-plugin-banner": "^0.2.1",
"rollup-plugin-banner2": "^1.2.2",
"rollup-plugin-terser": "^7.0.2",
"vinyl-buffer": "^1.0.1",
"run-sequence": "^2.2.1",
"sass": "^1.39.0",
"semver": "^7.3.8",
Expand Down
24 changes: 18 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef50d7e

Please sign in to comment.