mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
6c96e1cd7b
* 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
41 lines
790 B
JavaScript
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)
|
|
]
|
|
}
|
|
]
|