I'm following this tutorial trying to create a svelte frontend.
I don't get any errors but when I run npm run dev
i get:
which I'm supposed to see the new extra.css file created in the public folder. and so the page displayed is without any CSS and just plain li items instead of having materialize-css attributes.
my files:
rollup.config.js
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write('public/build/bundle.css');
}
}),
css({ output: 'public\extra.css'}),
...
...
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>Svelte app</title>
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='extra.css'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='build/bundle.css'>
<script defer src='/build/bundle.js'></script>
</head>
<body>
</body>
</html>
App.svelte
<script>
import '..\node_modules\materialize-css\dist\css\materialize.min.css';
import '..\node_modules\materialize-css\dist\js\materialize.min.js';
import { Router, Route } from 'svelte-routing';
import Navbar from './layout/Navbar.svelte';
import Home from './pages/Home.svelte';
import About from './pages/About.svelte';
</script>
<style>
</style>
<Router>
<Navbar>
<div class="container">
<Route path="/" component={Home} />
<Route path="/about" component={About} />
</div>
</Navbar>
</Router>
Navbar.svelte
<script>
import { Link } from 'svelte-routing';
</script>
<nav>
<div class="nav-wrapper">
<Link to="/" class="brand-logo">svelte app</Link>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
</ul>
</div>
</nav>
and i also found this question/answer on SO that seem to say that the tutorial is ok and working for people so i'm confused.