mirror of
https://github.com/basecamp/trix.git
synced 2026-05-17 12:00:38 +00:00
0403d53fdd
Removes the JavaScript and CSS file `FileUtils.cp` calls from `action_text-trix/Rakefile` so that the files can be generated by the existing tooling (`rollup.config.js` for JavaScript, `bin/sass-build` for CSS). With this change, the project is free to continue to utilize those tools to manage the files that will be included in the Gem, without needing to span the Ruby-NodeJS boundary.
118 lines
2.3 KiB
JavaScript
118 lines
2.3 KiB
JavaScript
import json from "@rollup/plugin-json"
|
|
import includePaths from "rollup-plugin-includepaths"
|
|
import commonjs from "@rollup/plugin-commonjs"
|
|
import { babel } from "@rollup/plugin-babel"
|
|
import nodeResolve from "@rollup/plugin-node-resolve"
|
|
import { terser } from "rollup-plugin-terser"
|
|
|
|
import { version } from "./package.json"
|
|
|
|
const year = new Date().getFullYear()
|
|
const banner = `/*\nTrix ${version}\nCopyright © ${year} 37signals, LLC\n */`
|
|
|
|
const plugins = [
|
|
json(),
|
|
includePaths({
|
|
paths: [ "src" ],
|
|
extensions: [ ".js" ]
|
|
}),
|
|
nodeResolve({ extensions: [ ".js" ] }),
|
|
commonjs({
|
|
extensions: [ ".js" ]
|
|
}),
|
|
babel({ babelHelpers: "bundled" }),
|
|
]
|
|
|
|
const defaultConfig = {
|
|
context: "window",
|
|
treeshake: false,
|
|
plugins: plugins,
|
|
watch: {
|
|
include: "src/**"
|
|
}
|
|
}
|
|
|
|
const terserConfig = terser({
|
|
mangle: true,
|
|
compress: true,
|
|
format: {
|
|
comments: function (node, comment) {
|
|
const text = comment.value
|
|
const type = comment.type
|
|
if (type == "comment2") {
|
|
// multiline comment
|
|
return /@license|Copyright/.test(text)
|
|
}
|
|
},
|
|
},
|
|
})
|
|
|
|
const compressedConfig = Object.assign({}, defaultConfig, { plugins: plugins.concat(terserConfig) })
|
|
|
|
export default [
|
|
{
|
|
input: "src/trix/trix.js",
|
|
output: [
|
|
{
|
|
name: "Trix",
|
|
file: "dist/trix.umd.js",
|
|
format: "umd",
|
|
banner
|
|
},
|
|
{
|
|
file: "dist/trix.esm.js",
|
|
format: "es",
|
|
banner
|
|
},
|
|
{
|
|
name: "Trix",
|
|
file: "action_text-trix/app/assets/javascripts/trix.js",
|
|
format: "umd",
|
|
banner
|
|
},
|
|
],
|
|
...defaultConfig,
|
|
},
|
|
{
|
|
input: "src/trix/trix.js",
|
|
output: [
|
|
{
|
|
name: "Trix",
|
|
file: "dist/trix.umd.min.js",
|
|
format: "umd",
|
|
banner,
|
|
sourcemap: true
|
|
},
|
|
{
|
|
file: "dist/trix.esm.min.js",
|
|
format: "es",
|
|
banner,
|
|
sourcemap: true
|
|
}
|
|
],
|
|
...compressedConfig,
|
|
},
|
|
{
|
|
input: "src/test/test.js",
|
|
output: {
|
|
name: "TrixTests",
|
|
file: "dist/test.js",
|
|
format: "es",
|
|
sourcemap: true,
|
|
banner
|
|
},
|
|
...defaultConfig,
|
|
},
|
|
{
|
|
input: "src/inspector/inspector.js",
|
|
output: {
|
|
name: "TrixInspector",
|
|
file: "dist/inspector.js",
|
|
format: "es",
|
|
sourcemap: true,
|
|
banner
|
|
},
|
|
...defaultConfig,
|
|
}
|
|
]
|