Skip to content

Commit

Permalink
Use rollup so we don't need to rely on sprockets
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 19, 2024
1 parent 17afd67 commit fa7a3a6
Show file tree
Hide file tree
Showing 11 changed files with 386 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.config
.yardoc
Gemfile.lock
package-lock.json
InstalledFiles
_yardoc
coverage
Expand All @@ -17,4 +18,5 @@ test/version_tmp
tmp
jetty
spec/internal
.internal_test_app
.internal_test_app
node_modules
162 changes: 162 additions & 0 deletions app/assets/javascripts/blacklight_gallery/blacklight-gallery.esm.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions app/assets/javascripts/blacklight_gallery/blacklight-gallery.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/javascript/blacklight_gallery/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'imagesloaded.min'
import 'masonry.min'

import './slideshow'
import './masonry'
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//= require blacklight_gallery/default
//= require blacklight_gallery/osd_viewer
import 'blacklight_gallery'
import OpenSeadragon from 'openseadragon'
window.OpenSeadragon = OpenSeadragon
import 'openseadragon-rails'
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "blacklight-gallery",
"version": "4.6.4",
"description": "Gallery views for Blacklight search results",
"main": "app/assets/javascripts/blacklight_gallery/default.js",
"main": "app/assets/javascripts/blacklight_gallery/blacklight-gallery.esm.js",
"type": "module",
"scripts": {
"prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap"
},
"files": [
"app/assets/javascripts/blacklight_gallery/*.js",
"vendor/assets/javascripts/*.js",
Expand All @@ -18,9 +22,13 @@
"url": "https://github.com/projectblacklight/blacklight-gallery/issues"
},
"homepage": "https://github.com/projectblacklight/blacklight-gallery#readme",
"devDependencies": { },
"devDependencies": {
"rollup": "^4.24.0",
"rollup-plugin-includepaths": "^0.2.4"
},
"dependencies": {
"blacklight-frontend": ">=7.1.0 <9",
"openseadragon-rails": "1.0.0",
"jquery": ">=3.0"
}
}
31 changes: 31 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import includePaths from 'rollup-plugin-includepaths';


const BUNDLE = process.env.BUNDLE === 'true'
const ESM = process.env.ESM === 'true'

const fileDest = `blacklight-gallery${ESM ? '.esm' : ''}`
const external = []
const globals = {}

let includePathOptions = {
include: {},
paths: ['app/javascript', 'vendor/assets/javascripts'],
external: [],
extensions: ['.js']
};

const rollupConfig = {
input: 'app/javascript/blacklight_gallery/index.js',
output: {
file: `app/assets/javascripts/blacklight_gallery/${fileDest}.js`,
format: ESM ? 'es' : 'umd',
globals,
generatedCode: { preset: 'es2015' },
name: ESM ? undefined : 'BlacklightGallery'
},
external,
plugins: [includePaths(includePathOptions)]
}

export default rollupConfig

0 comments on commit fa7a3a6

Please sign in to comment.