Skip to content

Commit

Permalink
migrate playground to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Apr 12, 2022
1 parent cf80a11 commit 76239d2
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 4,579 deletions.
8 changes: 5 additions & 3 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="bundle.js" async></script>
<script type="module" src="/index.js"></script>
</head>

<body id="body">
<turbo-stream action="log" target="body" message="hello world"></turbo-stream>

<turbo-stream action="append" target="body">
<template>
Append to body
</template>
</turbo-stream>

<turbo-stream action="append2" target="body">
<turbo-stream action="customAppend" target="body">
<template>
Append2 to body
customAppend to body
</template>
</turbo-stream>

Expand Down
6 changes: 5 additions & 1 deletion playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import * as Turbo from "@hotwired/turbo"
import CableReady from "cable_ready"
import CableStreams from "cable-streams"

CableStreams.customActions.append2 = function() {
CableStreams.customActions.customAppend = function() {
this.removeDuplicateTargetChildren()
this.targetElements.forEach(e => e.append(this.templateContent))
}

CableStreams.customActions.myCustomAction = function() {
console.log("Hello from my custom turbo stream action")
}

CableStreams.customActions.log = function() {
console.log(this.getAttribute("message"))
}
17 changes: 5 additions & 12 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@
"cable-streams": "link:../"
},
"scripts": {
"start": "webpack-dev-server --mode development --open"
"start": "yarn run dev",
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-modules": "^0.1.4",
"@babel/preset-react": "^7.16.7",
"babel-loader": "^8.1.0",
"css-loader": "^5.0.1",
"style-loader": "^2.0.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
"vite": "^2.8.0"
}
}
9 changes: 9 additions & 0 deletions playground/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');

export default {
resolve: {
alias: {
'cable-streams': path.resolve(__dirname, '../dist/index.js')
}
}
}
52 changes: 0 additions & 52 deletions playground/webpack.config.js

This file was deleted.

Loading

0 comments on commit 76239d2

Please sign in to comment.