1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/rollup.config.js
David Heinemeier Hansson 6c96e1cd7b
Move Active Storage JS to ESM and drop Babel transpiling (#42895)
* Move to ESM and drop Babel transpiling

* Make the activestorage JS directly available through the asset pipeline as a precompiled asset

* Use example with direct attachment

* Explain that direct reference is possible

* Active Storage JS is a module

* Retain umd asset for backwards compatibility, add ESM file in addition

* Explain how to use activestorage.esm with importmap

* Use untranspiled activestorage inclusion

* Don't repeat terser options
2021-07-28 15:17:13 -04:00

41 lines
790 B
JavaScript

import resolve from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"
import { terser } from "rollup-plugin-terser"
const terserOptions = {
mangle: false,
compress: false,
format: {
beautify: true,
indent_level: 2
}
}
export default [
{
input: "app/javascript/activestorage/index.js",
output: {
file: "app/assets/javascripts/activestorage.js",
format: "umd",
name: "ActiveStorage"
},
plugins: [
resolve(),
commonjs(),
terser(terserOptions)
]
},
{
input: "app/javascript/activestorage/index.js",
output: {
file: "app/assets/javascripts/activestorage.esm.js",
format: "es"
},
plugins: [
resolve(),
commonjs(),
terser(terserOptions)
]
}
]