From f0b01f1974a0356fb96648f4af475ab1e51011c4 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Tue, 19 Jan 2021 13:51:17 +0100 Subject: [PATCH] Better webpack config --- package-lock.json | 5 +++++ package.json | 2 ++ public/style.css | 5 ----- src/back/html.ts | 3 --- src/front/controllers/task_controller.ts | 4 +--- src/front/index.js | 6 ------ src/front/index.ts | 8 ++++++++ src/front/tsconfig.json | 2 +- webpack.config.js | 6 +++++- 9 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 src/front/index.js create mode 100644 src/front/index.ts diff --git a/package-lock.json b/package-lock.json index 2dc5cb6..676bb8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -283,6 +283,11 @@ "integrity": "sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg==", "dev": true }, + "@hotwired/turbo": { + "version": "7.0.0-beta.3", + "resolved": "https://registry.npmjs.org/@hotwired/turbo/-/turbo-7.0.0-beta.3.tgz", + "integrity": "sha512-lOyxOaZJBLxD8sGowjghkmCxuN4FcqYDciRI88DuzyXok35vK6nYewGSfZ4SOpb7McOJ5qVChEsUaBfmY+N8NA==" + }, "@koa/router": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/@koa/router/-/router-10.0.0.tgz", diff --git a/package.json b/package.json index 04377ba..d29c610 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "test": "./npm.sh run test-cmd -- ", "build:back": "tsc -p src/back", "build:front": "webpack", + "build": "npm run build:back && npm run build:front", "watch:back": "tsc --watch -p src/back", "watch:front": "webpack --watch", "watch": "concurrently npm:watch:back npm:watch:front", @@ -19,6 +20,7 @@ "license": "ISC", "dependencies": { "@babel/core": "^7.12.10", + "@hotwired/turbo": "^7.0.0-beta.3", "sealious": "^0.13.4", "stimulus": "^2.0.0" }, diff --git a/public/style.css b/public/style.css index 08c9e6c..91767ab 100644 --- a/public/style.css +++ b/public/style.css @@ -27,8 +27,3 @@ body { padding: 0.5rem; margin-left: 0.5rem; } - -turbo-frame { - border: 1px solid red; - display: block; -} diff --git a/src/back/html.ts b/src/back/html.ts index dee2b4f..69c66a5 100644 --- a/src/back/html.ts +++ b/src/back/html.ts @@ -3,9 +3,6 @@ export default function html(body: string): string { ${body} - `; } diff --git a/src/front/controllers/task_controller.ts b/src/front/controllers/task_controller.ts index 562b0a8..0048db7 100644 --- a/src/front/controllers/task_controller.ts +++ b/src/front/controllers/task_controller.ts @@ -1,8 +1,6 @@ import { Controller } from "stimulus"; -window; - -export default class extends Controller { +export default class TaskController extends Controller { id: string; connect() { diff --git a/src/front/index.js b/src/front/index.js deleted file mode 100644 index 0621652..0000000 --- a/src/front/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { Application } from "stimulus"; -import { definitionsFromContext } from "stimulus/webpack-helpers"; - -const application = Application.start(); -const context = require.context("./controllers", true, /\.[jt]s$/); -application.load(definitionsFromContext(context)); diff --git a/src/front/index.ts b/src/front/index.ts new file mode 100644 index 0000000..67ef81c --- /dev/null +++ b/src/front/index.ts @@ -0,0 +1,8 @@ +import * as Turbo from "@hotwired/turbo"; +import { Application } from "stimulus"; +import TaskController from "./controllers/task_controller"; + +export { Turbo }; + +const application = Application.start(); +application.register("task", TaskController); diff --git a/src/front/tsconfig.json b/src/front/tsconfig.json index b5b521a..b356529 100644 --- a/src/front/tsconfig.json +++ b/src/front/tsconfig.json @@ -4,5 +4,5 @@ "target": "ES6", "lib": ["dom"] }, - "include": ["./**/*"] + "include": ["./**/*", "./index.ts"] } diff --git a/webpack.config.js b/webpack.config.js index c017cff..443d05e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,7 +4,7 @@ module.exports = [ { name: "front-end-components", entry: { - bundle: "./src/front/index.js", + bundle: "./src/front/index.ts", }, output: { @@ -15,6 +15,10 @@ module.exports = [ mode: "production", devtool: "source-map", + resolve: { + extensions: [".ts", ".js"], + }, + module: { rules: [ {