mirror of
https://github.com/simonw/datasette.git
synced 2026-09-09 18:14:06 +02:00
Version-agnostic CodeMirror bundle filenames, rollup.config.mjs build
cm-editor-6.0.1.{js,bundle.js} -> cm-editor.{js,bundle.js}; new
npm run build:codemirror replaces the documented rollup one-liner.
Cache busting already handled by the static() template helper's
?_hash= content hash.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
79f6ac3f47
commit
28d811320b
6 changed files with 19 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script src="{{ static('sql-formatter-2.3.3.min.js') }}" defer></script>
|
||||
<script src="{{ static('cm-editor-6.0.1.bundle.js') }}"></script>
|
||||
<script src="{{ static('cm-editor.bundle.js') }}"></script>
|
||||
<style>
|
||||
.cm-editor {
|
||||
resize: both;
|
||||
|
|
|
|||
|
|
@ -434,13 +434,10 @@ Datasette bundles `CodeMirror <https://codemirror.net/>`__ for the SQL editing i
|
|||
|
||||
npm i codemirror @codemirror/lang-sql
|
||||
|
||||
* Build the bundle using the version number from package.json with::
|
||||
* Build the bundle with::
|
||||
|
||||
node_modules/.bin/rollup datasette/static/cm-editor-6.0.1.js \
|
||||
-f iife \
|
||||
-n cm \
|
||||
-o datasette/static/cm-editor-6.0.1.bundle.js \
|
||||
-p @rollup/plugin-node-resolve \
|
||||
-p @rollup/plugin-terser
|
||||
npm install && npm run build:codemirror
|
||||
|
||||
* Update the version reference in the ``codemirror.html`` template.
|
||||
This runs ``rollup -c`` against the ``rollup.config.mjs`` file at the root of the repository, which reads ``datasette/static/cm-editor.js`` and writes the bundled, minified output to ``datasette/static/cm-editor.bundle.js``. The bundle filename does not include the CodeMirror version number, so no template needs to be updated.
|
||||
|
||||
* Commit the rebuilt ``datasette/static/cm-editor.bundle.js`` - the bundle is checked into the repository.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
"prettier": "^3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build:codemirror": "rollup -c",
|
||||
"fix": "npm run prettier -- --write",
|
||||
"prettier": "prettier 'datasette/static/*[!.min|bundle].js'"
|
||||
},
|
||||
|
|
|
|||
12
rollup.config.mjs
Normal file
12
rollup.config.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
|
||||
export default {
|
||||
input: "datasette/static/cm-editor.js",
|
||||
output: {
|
||||
file: "datasette/static/cm-editor.bundle.js",
|
||||
format: "iife",
|
||||
name: "cm",
|
||||
},
|
||||
plugins: [nodeResolve(), terser()],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue