mirror of
https://github.com/kognise/water.css.git
synced 2025-08-22 04:43:09 +02:00
Fix script
This commit is contained in:
14
dev.js
14
dev.js
@@ -18,6 +18,13 @@ app.get('/', async (req, res) => {
|
|||||||
res.send(injected)
|
res.send(injected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.get('/script.js', async (req, res) => {
|
||||||
|
console.log('> Serving script')
|
||||||
|
const script = await fs.readFile('script.js')
|
||||||
|
res.contentType('javascript')
|
||||||
|
res.send(script)
|
||||||
|
})
|
||||||
|
|
||||||
app.use('/dist', (req, res, next) => {
|
app.use('/dist', (req, res, next) => {
|
||||||
console.log('> Serving a stylesheet')
|
console.log('> Serving a stylesheet')
|
||||||
next()
|
next()
|
||||||
@@ -33,7 +40,12 @@ chokidar.watch('index.html', { ignoreInitial: true }).on('all', () => {
|
|||||||
reload()
|
reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
chokidar.watch('src/*.scss', { ignoreInitial: true }).on('all', async (event, file) => {
|
chokidar.watch('script.js', { ignoreInitial: true }).on('all', () => {
|
||||||
|
console.log('> Script changed')
|
||||||
|
reload()
|
||||||
|
})
|
||||||
|
|
||||||
|
chokidar.watch('src/*.scss', { ignoreInitial: true }).on('all', (event, file) => {
|
||||||
console.log('> Stylesheet changed')
|
console.log('> Stylesheet changed')
|
||||||
sass.render({ file, outputStyle: 'compressed' }, async (errors, { css }) => {
|
sass.render({ file, outputStyle: 'compressed' }, async (errors, { css }) => {
|
||||||
if (errors) {
|
if (errors) {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
<head>
|
<head>
|
||||||
<title>Water.css</title>
|
<title>Water.css</title>
|
||||||
<link id='stylesheet' rel='stylesheet' href='dist/light.css'>
|
<link id='stylesheet' rel='stylesheet' href='dist/dark.css'>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
|
|
||||||
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-116663597-6'></script>
|
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-116663597-6'></script>
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
document.getElementById('switch').addEventListener('click', () => {
|
document.getElementById('switch').addEventListener('click', () => {
|
||||||
const stylesheet = document.getElementById('stylesheet')
|
const stylesheet = document.getElementById('stylesheet')
|
||||||
|
const ph = document.getElementById('ph')
|
||||||
if (stylesheet.getAttribute('href') === 'dist/dark.css') {
|
if (stylesheet.getAttribute('href') === 'dist/dark.css') {
|
||||||
stylesheet.setAttribute('href', 'dist/light.css')
|
stylesheet.setAttribute('href', 'dist/light.css')
|
||||||
|
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
||||||
} else {
|
} else {
|
||||||
stylesheet.setAttribute('href', 'dist/dark.css')
|
stylesheet.setAttribute('href', 'dist/dark.css')
|
||||||
|
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
||||||
}
|
}
|
||||||
})
|
})
|
Reference in New Issue
Block a user