-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from stimulusreflex/ship-prebuilt-js-with-gem
Ship prebuilt js with gem
- Loading branch information
Showing
14 changed files
with
468 additions
and
95 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Empty file.
Empty file.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,23 @@ | ||
module Futurism | ||
class Engine < ::Rails::Engine | ||
initializer "futurism.assets" do |app| | ||
if app.config.respond_to?(:assets) | ||
app.config.assets.precompile += %w[ | ||
futurism.js | ||
futurism.min.js | ||
futurism.min.js.map | ||
futurism.umd.js | ||
futurism.umd.min.js | ||
futurism.umd.min.js.map | ||
] | ||
end | ||
end | ||
|
||
initializer "futurism.importmap", before: "importmap" do |app| | ||
if app.config.respond_to?(:importmap) | ||
app.config.importmap.paths << Engine.root.join("lib/futurism/importmap.rb") | ||
app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts") | ||
end | ||
end | ||
end | ||
end |
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,2 @@ | ||
pin "cable_ready", to: "cable_ready.min.js", preload: true | ||
pin "futurism", to: "futurism.min.js", preload: true |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Futurism | ||
VERSION = "1.2.0.pre9" | ||
VERSION = "1.2.0.pre10" | ||
end |
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,47 @@ | ||
{ | ||
"name": "@stimulus_reflex/futurism", | ||
"version": "1.2.0-pre10", | ||
"description": "Lazy-load Rails partials via CableReady", | ||
"main": "./dist/futurism.umd.min.js", | ||
"module": "./dist/futurism.min.js", | ||
"files": [ | ||
"dist/*", | ||
"javascript/*" | ||
], | ||
"scripts": { | ||
"test": "yarn run mocha", | ||
"lint": "yarn run prettier-standard:check", | ||
"format": "yarn run prettier-standard:format", | ||
"prettier-standard:check": "yarn run prettier-standard --check ./javascript/**/*.js rollup.config.js", | ||
"prettier-standard:format": "yarn run prettier-standard ./javascript/**/*.js rollup.config.js", | ||
"build": "yarn rollup -c", | ||
"watch": "yarn rollup -wc" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/stimulusreflex/futurism.git" | ||
}, | ||
"keywords": [ | ||
"cable_ready", | ||
"lazy", | ||
"loading" | ||
], | ||
"author": "Julian Rubisch <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/stimulusreflex/futurism/issues" | ||
}, | ||
"homepage": "https://github.com/stimulusreflex/futurism#readme", | ||
"dependencies": { | ||
"cable_ready": "^5.0.0-pre9" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^21.0.3", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.1.3", | ||
"mocha": "^8.0.1", | ||
"prettier-standard": "^16.4.1", | ||
"rollup": "^2.70.1", | ||
"rollup-plugin-terser": "^7.0.2" | ||
} | ||
} |
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,77 @@ | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import json from '@rollup/plugin-json' | ||
import { terser } from 'rollup-plugin-terser' | ||
|
||
const pretty = () => { | ||
return terser({ | ||
mangle: false, | ||
compress: false, | ||
format: { | ||
beautify: true, | ||
indent_level: 2 | ||
} | ||
}) | ||
} | ||
|
||
const minify = () => { | ||
return terser({ | ||
mangle: true, | ||
compress: true | ||
}) | ||
} | ||
|
||
const esConfig = { | ||
format: 'es', | ||
inlineDynamicImports: true | ||
} | ||
|
||
const umdConfig = { | ||
name: 'Futurism', | ||
format: 'umd', | ||
exports: 'named', | ||
globals: { | ||
cable_ready: 'CableReady' | ||
} | ||
} | ||
|
||
const distFolders = ['dist/', 'app/assets/javascripts/'] | ||
|
||
const output = distFolders | ||
.map(distFolder => [ | ||
{ | ||
...esConfig, | ||
file: `${distFolder}/futurism.js`, | ||
plugins: [pretty()] | ||
}, | ||
{ | ||
...esConfig, | ||
file: `${distFolder}/futurism.min.js`, | ||
sourcemap: true, | ||
plugins: [minify()] | ||
}, | ||
{ | ||
...umdConfig, | ||
file: `${distFolder}/futurism.umd.js`, | ||
plugins: [pretty()] | ||
}, | ||
{ | ||
...umdConfig, | ||
file: `${distFolder}/futurism.umd.min.js`, | ||
sourcemap: true, | ||
plugins: [minify()] | ||
} | ||
]) | ||
.flat() | ||
|
||
export default [ | ||
{ | ||
external: ['cable_ready'], | ||
input: 'javascript/index.js', | ||
output, | ||
plugins: [commonjs(), resolve(), json()], | ||
watch: { | ||
include: 'javascript/**' | ||
} | ||
} | ||
] |
Oops, something went wrong.