Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Cris Fandino committed Feb 4, 2021
1 parent 5e2de70 commit d715abf
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/

client/node_modules/`
client/node_modules/
23 changes: 13 additions & 10 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"build": "rollup -c ",
"dev": "rollup -c -w",
"start": "sirv public"
},
Expand All @@ -22,6 +22,7 @@
"tailwindcss": "^2.0.2"
},
"dependencies": {
"@rollup/plugin-replace": "^2.3.4",
"sirv-cli": "^1.0.0",
"socket.io-client": "^3.1.0"
}
Expand Down
12 changes: 9 additions & 3 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<title>Svelte app</title>

<title>Chat - App</title>
<meta name="description" content="Simple chat app and creating room" />
<meta name="og:description" content="Simple chat app and creating room" />
<meta
name="twitter:description"
content="Simple chat app and creating room"
/>
<meta name="theme-color" content="#2196f3" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="stylesheet" href="/build/bundle.css" />

<link rel="manifest" href="manifest.json" />
<script defer src="/build/bundle.js"></script>
</head>

Expand Down
7 changes: 7 additions & 0 deletions client/public/manifes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"theme_color": "#2196f3",
"background_color": "#2196f3",
"display": "browser",
"scope": "/",
"start_url": "/"
}
4 changes: 4 additions & 0 deletions client/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import css from 'rollup-plugin-css-only'
import sveltePreprocess from 'svelte-preprocess'
import replace from '@rollup/plugin-replace'

const production = !process.env.ROLLUP_WATCH

Expand Down Expand Up @@ -42,6 +43,9 @@ export default {
file: 'public/build/bundle.js',
},
plugins: [
replace({
'process.env.isProd': production,
}),
svelte({
preprocess: sveltePreprocess({ postcss: true }),
compilerOptions: {
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { createEventDispatcher } from 'svelte'
const dispathcer = createEventDispatcher()
export let variant = 'primary'
function forward(e) {
dispathcer('click', e)
Expand Down
4 changes: 4 additions & 0 deletions client/src/const.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export const ID_KEY = 'chat-app.id'

export const SOCKET_ENDPOINT = !process.env.isProd
? 'http://localhost:3000/'
: 'https://morning-oasis-02038.herokuapp.com/'
4 changes: 2 additions & 2 deletions client/src/store.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import io from 'socket.io-client'
import { writable } from 'svelte/store'
import { ID_KEY } from './const'
import { ID_KEY, SOCKET_ENDPOINT } from './const'

export const users = writable([])
export const loggedUser = writable()

export const socket = io('http://localhost:3000', {
export const socket = io(SOCKET_ENDPOINT, {
transports: ['websocket', 'polling'],
})

Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ io.on('connection', (socket) => {
socket.on('user-leave', handleLeaveAndDisconnect)
})

http.listen(3000, () => {
console.log('listening on port 3000')
const PORT = process.env.PORT || 3000

http.listen(PORT, () => {
console.log(`listening on port ${PORT}`)
})

0 comments on commit d715abf

Please sign in to comment.