mirror of
https://github.com/kognise/water.css.git
synced 2025-08-21 12:22:00 +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)
|
||||
})
|
||||
|
||||
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) => {
|
||||
console.log('> Serving a stylesheet')
|
||||
next()
|
||||
@@ -33,7 +40,12 @@ chokidar.watch('index.html', { ignoreInitial: true }).on('all', () => {
|
||||
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')
|
||||
sass.render({ file, outputStyle: 'compressed' }, async (errors, { css }) => {
|
||||
if (errors) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<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'>
|
||||
|
||||
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-116663597-6'></script>
|
||||
|
@@ -1,8 +1,11 @@
|
||||
document.getElementById('switch').addEventListener('click', () => {
|
||||
const stylesheet = document.getElementById('stylesheet')
|
||||
const ph = document.getElementById('ph')
|
||||
if (stylesheet.getAttribute('href') === 'dist/dark.css') {
|
||||
stylesheet.setAttribute('href', 'dist/light.css')
|
||||
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
||||
} else {
|
||||
stylesheet.setAttribute('href', 'dist/dark.css')
|
||||
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user