I've successfully managed to get Tailwind CSS working in Rails 7 using the tailwindcss-rails
gem (through rails new testapp -css tailwind
).
Some of the interactive items (like menu drop down) don't work because it requires JS. So I ran bin/importmap pin tailwindcss
which installed a bunch of plugins in importmap.rb
:
pin "tailwindcss", to: "https://ga.jspm.io/npm:[email protected]/lib/index.js"
pin "@nodelib/fs.scandir", to: "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js"
pin "@nodelib/fs.stat", to: "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js"
pin "@nodelib/fs.walk", to: "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js"
pin "acorn", to: "https://ga.jspm.io/npm:[email protected]/dist/acorn.js"
pin "acorn-node", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "acorn-node/walk", to: "https://ga.jspm.io/npm:[email protected]/walk.js"
pin "acorn-walk", to: "https://ga.jspm.io/npm:[email protected]/dist/walk.js"
pin "ansi-styles", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "anymatch", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "assert", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/assert.js"
pin "balanced-match", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "binary-extensions", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "brace-expansion", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "braces", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "buffer", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js"
pin "camelcase-css", to: "https://ga.jspm.io/npm:[email protected]/index-es5.js"
pin "chalk", to: "https://ga.jspm.io/npm:[email protected]/source/index.js"
pin "chokidar", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "color-convert", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "color-name", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "concat-map", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "crypto", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/crypto.js"
pin "cssesc", to: "https://ga.jspm.io/npm:[email protected]/cssesc.js"
pin "defined", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "detective", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "didyoumean", to: "https://ga.jspm.io/npm:[email protected]/didYouMean-1.2.1.js"
pin "dlv", to: "https://ga.jspm.io/npm:[email protected]/dist/dlv.umd.js"
pin "events", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/events.js"
pin "fast-glob", to: "https://ga.jspm.io/npm:[email protected]/out/index.js"
pin "fastq", to: "https://ga.jspm.io/npm:[email protected]/queue.js"
pin "fill-range", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "fs", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js"
pin "fs.realpath", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "fsevents", to: "https://ga.jspm.io/npm:[email protected]/fsevents.js"
pin "function-bind", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "glob", to: "https://ga.jspm.io/npm:[email protected]/glob.js"
pin "glob-parent", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "has", to: "https://ga.jspm.io/npm:[email protected]/src/index.js"
pin "inflight", to: "https://ga.jspm.io/npm:[email protected]/inflight.js"
pin "inherits", to: "https://ga.jspm.io/npm:[email protected]/inherits_browser.js"
pin "is-binary-path", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "is-core-module", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "is-extglob", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "is-glob", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "is-number", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "merge2", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "micromatch", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "minimatch", to: "https://ga.jspm.io/npm:[email protected]/minimatch.js"
pin "nanoid/non-secure", to: "https://ga.jspm.io/npm:[email protected]/non-secure/index.cjs"
pin "normalize-path", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "object-hash", to: "https://ga.jspm.io/npm:[email protected]/dist/object_hash.js"
pin "once", to: "https://ga.jspm.io/npm:[email protected]/once.js"
pin "os", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/os.js"
pin "path", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js"
pin "path-is-absolute", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "path-parse", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "picocolors", to: "https://ga.jspm.io/npm:[email protected]/picocolors.browser.js"
pin "picomatch", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "picomatch/lib/utils", to: "https://ga.jspm.io/npm:[email protected]/lib/utils.js"
pin "postcss", to: "https://ga.jspm.io/npm:[email protected]/lib/postcss.js"
pin "postcss-js", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "postcss-nested", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "postcss-selector-parser", to: "https://ga.jspm.io/npm:[email protected]/dist/index.js"
pin "postcss-selector-parser/dist/util/unesc", to: "https://ga.jspm.io/npm:[email protected]/dist/util/unesc.js"
pin "postcss-value-parser", to: "https://ga.jspm.io/npm:[email protected]/lib/index.js"
pin "process", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process-production.js"
pin "queue-microtask", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "quick-lru", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "readdirp", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "resolve", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "reusify", to: "https://ga.jspm.io/npm:[email protected]/reusify.js"
pin "rimraf", to: "https://ga.jspm.io/npm:[email protected]/rimraf.js"
pin "run-parallel", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "source-map-js", to: "https://ga.jspm.io/npm:[email protected]/source-map.js"
pin "stream", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/stream.js"
pin "supports-color", to: "https://ga.jspm.io/npm:[email protected]/browser.js"
pin "tmp", to: "https://ga.jspm.io/npm:[email protected]/lib/tmp.js"
pin "to-regex-range", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "url", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js"
pin "util", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/util.js"
pin "util-deprecate", to: "https://ga.jspm.io/npm:[email protected]/browser.js"
pin "wrappy", to: "https://ga.jspm.io/npm:[email protected]/wrappy.js"
pin "xtend", to: "https://ga.jspm.io/npm:[email protected]/immutable.js"
I can see this appearing in the browser (latest Chrome) but none of the interactive items work:
<script type="importmap" data-turbo-track="reload">{
"imports": {
"application": "/assets/application-31435dd5f3e00b80f6f70482d4001362501166da1a87a9b9fd72083d43666ad9.js",
"@hotwired/turbo-rails": "/assets/turbo.min-305f0d205866ac9fc3667580728220ae0c3b499e5f15df7c4daaeee4d03b5ac1.js",
"@hotwired/stimulus": "/assets/stimulus.min-900648768bd96f3faeba359cf33c1bd01ca424ca4d2d05f36a5d8345112ae93c.js",
"@hotwired/stimulus-loading": "/assets/stimulus-loading-685d40a0b68f785d3cdbab1c0f3575320497462e335c4a63b8de40a355d883c0.js",
"@popperjs/core": "https://ga.jspm.io/npm:@popperjs/[email protected]/lib/index.js",
"jquery": "https://ga.jspm.io/npm:[email protected]/dist/jquery.js",
"tailwindcss": "https://ga.jspm.io/npm:[email protected]/lib/index.js",
"@nodelib/fs.scandir": "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js",
"@nodelib/fs.stat": "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js",
"@nodelib/fs.walk": "https://ga.jspm.io/npm:@nodelib/[email protected]/out/index.js",
"acorn": "https://ga.jspm.io/npm:[email protected]/dist/acorn.js",
"acorn-node": "https://ga.jspm.io/npm:[email protected]/index.js",
"acorn-node/walk": "https://ga.jspm.io/npm:[email protected]/walk.js",
"acorn-walk": "https://ga.jspm.io/npm:[email protected]/dist/walk.js",
"anymatch": "https://ga.jspm.io/npm:[email protected]/index.js",
"balanced-match": "https://ga.jspm.io/npm:[email protected]/index.js",
"binary-extensions": "https://ga.jspm.io/npm:[email protected]/index.js",
"brace-expansion": "https://ga.jspm.io/npm:[email protected]/index.js",
"braces": "https://ga.jspm.io/npm:[email protected]/index.js",
"camelcase-css": "https://ga.jspm.io/npm:[email protected]/index-es5.js",
"chokidar": "https://ga.jspm.io/npm:[email protected]/index.js",
"concat-map": "https://ga.jspm.io/npm:[email protected]/index.js",
"cssesc": "https://ga.jspm.io/npm:[email protected]/cssesc.js",
"defined": "https://ga.jspm.io/npm:[email protected]/index.js",
"detective": "https://ga.jspm.io/npm:[email protected]/index.js",
"didyoumean": "https://ga.jspm.io/npm:[email protected]/didYouMean-1.2.1.js",
"dlv": "https://ga.jspm.io/npm:[email protected]/dist/dlv.umd.js",
"fast-glob": "https://ga.jspm.io/npm:[email protected]/out/index.js",
"fastq": "https://ga.jspm.io/npm:[email protected]/queue.js",
"fill-range": "https://ga.jspm.io/npm:[email protected]/index.js",
"fs.realpath": "https://ga.jspm.io/npm:[email protected]/index.js",
"fsevents": "https://ga.jspm.io/npm:[email protected]/fsevents.js",
"glob": "https://ga.jspm.io/npm:[email protected]/glob.js",
"glob-parent": "https://ga.jspm.io/npm:[email protected]/index.js",
"inflight": "https://ga.jspm.io/npm:[email protected]/inflight.js",
"is-binary-path": "https://ga.jspm.io/npm:[email protected]/index.js",
"is-core-module": "https://ga.jspm.io/npm:[email protected]/index.js",
"is-extglob": "https://ga.jspm.io/npm:[email protected]/index.js",
"is-glob": "https://ga.jspm.io/npm:[email protected]/index.js",
"is-number": "https://ga.jspm.io/npm:[email protected]/index.js",
"merge2": "https://ga.jspm.io/npm:[email protected]/index.js",
"micromatch": "https://ga.jspm.io/npm:[email protected]/index.js",
"minimatch": "https://ga.jspm.io/npm:[email protected]/minimatch.js",
"nanoid/non-secure": "https://ga.jspm.io/npm:[email protected]/non-secure/index.cjs",
"normalize-path": "https://ga.jspm.io/npm:[email protected]/index.js",
"object-hash": "https://ga.jspm.io/npm:[email protected]/dist/object_hash.js",
"once": "https://ga.jspm.io/npm:[email protected]/once.js",
"path-is-absolute": "https://ga.jspm.io/npm:[email protected]/index.js",
"path-parse": "https://ga.jspm.io/npm:[email protected]/index.js",
"picocolors": "https://ga.jspm.io/npm:[email protected]/picocolors.browser.js",
"picomatch": "https://ga.jspm.io/npm:[email protected]/index.js",
"picomatch/lib/utils": "https://ga.jspm.io/npm:[email protected]/lib/utils.js",
"postcss": "https://ga.jspm.io/npm:[email protected]/lib/postcss.js",
"postcss-js": "https://ga.jspm.io/npm:[email protected]/index.js",
"postcss-nested": "https://ga.jspm.io/npm:[email protected]/index.js",
"postcss-selector-parser": "https://ga.jspm.io/npm:[email protected]/dist/index.js",
"postcss-selector-parser/dist/util/unesc": "https://ga.jspm.io/npm:[email protected]/dist/util/unesc.js",
"postcss-value-parser": "https://ga.jspm.io/npm:[email protected]/lib/index.js",
"queue-microtask": "https://ga.jspm.io/npm:[email protected]/index.js",
"quick-lru": "https://ga.jspm.io/npm:[email protected]/index.js",
"readdirp": "https://ga.jspm.io/npm:[email protected]/index.js",
"resolve": "https://ga.jspm.io/npm:[email protected]/index.js",
"reusify": "https://ga.jspm.io/npm:[email protected]/reusify.js",
"rimraf": "https://ga.jspm.io/npm:[email protected]/rimraf.js",
"run-parallel": "https://ga.jspm.io/npm:[email protected]/index.js",
"source-map-js": "https://ga.jspm.io/npm:[email protected]/source-map.js",
"tmp": "https://ga.jspm.io/npm:[email protected]/lib/tmp.js",
"to-regex-range": "https://ga.jspm.io/npm:[email protected]/index.js",
"util-deprecate": "https://ga.jspm.io/npm:[email protected]/browser.js",
"wrappy": "https://ga.jspm.io/npm:[email protected]/wrappy.js",
"xtend": "https://ga.jspm.io/npm:[email protected]/immutable.js",
"ansi-styles": "https://ga.jspm.io/npm:[email protected]/index.js",
"assert": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/assert.js",
"buffer": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js",
"chalk": "https://ga.jspm.io/npm:[email protected]/source/index.js",
"color-convert": "https://ga.jspm.io/npm:[email protected]/index.js",
"color-name": "https://ga.jspm.io/npm:[email protected]/index.js",
"crypto": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/crypto.js",
"events": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/events.js",
"fs": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
"function-bind": "https://ga.jspm.io/npm:[email protected]/index.js",
"has": "https://ga.jspm.io/npm:[email protected]/src/index.js",
"inherits": "https://ga.jspm.io/npm:[email protected]/inherits_browser.js",
"os": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/os.js",
"path": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js",
"process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process-production.js",
"stream": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/stream.js",
"supports-color": "https://ga.jspm.io/npm:[email protected]/browser.js",
"url": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js",
"util": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/util.js",
"controllers/application": "/assets/controllers/application-368d98631bccbf2349e0d4f8269afb3fe9625118341966de054759d96ea86c7e.js",
"controllers/hello_controller": "/assets/controllers/hello_controller-549135e8e7c683a538c3d6d517339ba470fcfb79d62f738a0a089ba41851a554.js",
"controllers": "/assets/controllers/index-2db729dddcc5b979110e98de4b6720f83f91a123172e87281d5a58410fc43806.js"
}
}</script>
I'm not very good at JavaScript, what am I missing? Do I need to initialise something somewhere?
Thank you