Skip to content

Commit 0a03f29

Browse files
committed
Switch to ESBuild
1 parent 3b1a3dd commit 0a03f29

File tree

8 files changed

+444
-4944
lines changed

8 files changed

+444
-4944
lines changed

Procfile.dev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
system_check: script/system_check && sleep 100000
22
web: lucky watch --reload-browser
3-
assets: yarn watch
3+
js_assets: yarn watch:js
4+
css_assets: yarn watch:css

dockerfiles/webserver.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ COPY shard.yml shard.lock ./
77
RUN shards install --production
88

99
# Install the application Yarn dependencies, then compile production CSS/JS
10-
FROM node:16-alpine as webpack_build
11-
WORKDIR /webpack
10+
FROM node:16-alpine as asset_build
11+
WORKDIR /asset
1212
COPY . .
1313
RUN yarn install
1414
RUN yarn run prod
@@ -19,7 +19,7 @@ ENV LUCKY_ENV=production
1919
RUN apk --no-cache add yaml-static
2020
COPY . .
2121
COPY --from=crystal_dependencies /shards/lib lib
22-
COPY --from=webpack_build /webpack/public public
22+
COPY --from=asset_build /asset/public public
2323
RUN crystal build --static --release tasks.cr -o /usr/local/bin/lucky
2424

2525
# Build the webserver binary
@@ -29,7 +29,7 @@ RUN apk --no-cache add yaml-static
2929
ENV LUCKY_ENV=production
3030
COPY . .
3131
COPY --from=crystal_dependencies /shards/lib lib
32-
COPY --from=webpack_build /webpack/public public
32+
COPY --from=asset_build /asset/public public
3333
RUN shards build --production --static --release
3434
RUN mv ./bin/webserver /usr/local/bin/webserver
3535

@@ -40,5 +40,5 @@ RUN apk --no-cache add diffutils
4040
COPY generated generated
4141
COPY --from=lucky_tasks_build /usr/local/bin/lucky /usr/local/bin/lucky
4242
COPY --from=lucky_webserver_build /usr/local/bin/webserver webserver
43-
COPY --from=webpack_build /webpack/public public
43+
COPY --from=asset_build /asset/public public
4444
CMD ["./webserver"]

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
"private": true,
44
"dependencies": {
55
"@hotwired/stimulus": "^3.1.0",
6-
"@hotwired/stimulus-webpack-helpers": "^1.0.1",
76
"@rails/ujs": "^7.0.3",
87
"@tailwindcss/aspect-ratio": "^0.4.2",
98
"@tailwindcss/forms": "^0.5.3",
109
"@tailwindcss/typography": "^0.5.7",
10+
"autoprefixer": "^10.4.8",
1111
"diff2html": "^3.4.19",
12+
"esbuild": "^0.15.7",
1213
"highlight.js": "^11.6.0",
1314
"postcss": "^8.4.16",
1415
"tailwindcss": "^3.1.8",
1516
"turbolinks": "^5.2.0"
1617
},
1718
"scripts": {
1819
"heroku-postbuild": "yarn prod",
19-
"dev": "mix",
20-
"watch": "mix watch",
21-
"prod": "mix --production"
20+
"build:js": "esbuild src/js/app.ts --bundle --sourcemap=inline --target=es2016 --outfile=public/js/app.js",
21+
"build:css": "tailwindcss --postcss --input=src/css/app.css --output=public/css/app.css",
22+
"watch:js": "esbuild src/js/app.ts --bundle --watch --sourcemap=inline --target=es2016 --outfile=public/js/app.js",
23+
"watch:css": "tailwindcss --postcss --watch --input=src/css/app.css --output=public/css/app.css",
24+
"prod:js": "esbuild src/js/app.ts --bundle --minify --sourcemap=inline --target=es2016 --outfile=public/js/app.js",
25+
"prod:css": "tailwindcss --postcss --minify --input=src/css/app.css --output=public/css/app.css",
26+
"prod": "yarn prod:js && yarn prod:css"
2227
},
2328
"devDependencies": {
24-
"@babel/compat-data": "^7.19.0",
2529
"@types/node": "^18.7.15",
26-
"@types/webpack-env": "^1.17.0",
2730
"browser-sync": "^2.27.10",
28-
"compression-webpack-plugin": "^10.0.0",
29-
"laravel-mix": "^6.0.49",
3031
"prettier": "^2.7.1",
3132
"resolve-url-loader": "5.0.0",
32-
"ts-loader": "^9.3.1",
3333
"typescript": "^4.8.2"
3434
}
3535
}

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
autoprefixer: {},
4+
tailwindcss: {},
5+
},
6+
};

src/js/app.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ require("@rails/ujs").start();
77
// Turbolinks is optional. Learn more: https://github.com/turbolinks/turbolinks/
88
require("turbolinks").start();
99

10+
// If using Turbolinks, you can attach events to page load like this:
11+
//
12+
// document.addEventListener("turbolinks:load", function() {
13+
// ...
14+
// })
15+
1016
import { Application } from "@hotwired/stimulus";
11-
import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers";
1217

13-
const application = Application.start();
14-
const context = require.context("./controllers", true, /\.ts$/);
15-
application.load(definitionsFromContext(context));
18+
import DiffToHtmlController from "./controllers/diff_to_html_controller";
19+
20+
declare global {
21+
interface Window {
22+
Stimulus: any;
23+
}
24+
}
25+
26+
let Stimulus = (window.Stimulus = Application.start());
27+
Stimulus.register("diff-to-html", DiffToHtmlController);
File renamed without changes.

webpack.mix.js

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)