Skip to content

Commit

Permalink
Compile javascript assets
Browse files Browse the repository at this point in the history
This will enable us to write javascript in es6+ and compile it into a
bundle for distribution.
  • Loading branch information
jcoyne committed Sep 9, 2017
1 parent da11007 commit adbe81c
Show file tree
Hide file tree
Showing 19 changed files with 2,422 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pkg/*
.internal_test_app
.vagrant
/spec/examples.txt
node_modules/*
23 changes: 23 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.*
Gemfile
Rakefile
Vagrantfile
app/assets/images
app/controllers
app/helpers
app/models
app/presenters
app/services
app/views
blacklight.gemspec
config/locales
config/routes.rb
coverage
db
lib
pkg
provision.sh
solr
spec
tasks
template.demo.rb
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You can use Blacklight to enable searching and browsing of your collections.
Blacklight uses the [Apache Solr](http://lucene.apache.org/solr) search engine
to search full text and/or metadata. Blacklight has a highly
configurable Ruby on Rails front-end. Blacklight was originally developed at
the University of Virginia Library and is made public under an Apache 2.0 license.
the University of Virginia Library and is made public under an Apache 2.0 license.

## Installation

Expand Down Expand Up @@ -38,5 +38,40 @@ rails generate blacklight:install
* Bundler
* Rails 5.0+

## Configuring Apache Solr
## Configuring Apache Solr
You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR)

## Building the javascript
The javascript is built by npm from sources in `app/javascript` into a bundle
in `app/assets/javascripts/blacklight/blacklight.js`. This file should not be edited
by hand as any changes would be overwritten.

This is accomplished with the following steps:
1. Install npm
1. run `npm install` to download dependencies
1. run `npm run-script js-compile-bundle` to build the bundle

## Using the javascript
Install Webpacker
Add blacklight-frontend as a dependency by doing:
```
yarn add blacklight-frontend
```

Then add this to `config/webpack/shared.js` as per https://getbootstrap.com/docs/4.0/getting-started/webpack/
```
module.exports = [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
})
...
]
```

In you pack file, require blacklight:
```
require('blacklight-frontend/app/assets/javascripts/blacklight/blacklight')
```
Loading

0 comments on commit adbe81c

Please sign in to comment.