template
template copied to clipboard
No CSS sourcemaps
CSS sourcemaps used to be emitted fine but now they're not. No instructions on how to get them back.
got the same issue, when trying to run a downloaded repl. This is the terminal output for npm run dev:
> sirv public --no-clear "--dev"
Your application is ready~! 🚀
- Local: http://localhost:5000
- Network: Add `--host` to expose
────────────────── LOGS ──────────────────
[15:06:46] 200 ─ 5.94ms ─ /
[15:06:47] 200 ─ 1.80ms ─ /build/bundle.js
[15:06:47] 200 ─ 2.67ms ─ /build/bundle.js.map
[15:06:47] 404 ─ 0.13ms ─ /build/bundle.css.map <---- note the 404
This is my rollup.config.js - only custom thing should be the replace plugin
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
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;
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
replace({
// https://medium.com/dev-cafe/how-to-setup-env-variables-to-your-svelte-js-app-c1579430f032
process: JSON.stringify({
env: {
NODE_ENV: production ? 'prod' : 'debug',
},
}),
preventAssignment: true,
}),
svelte({
compilerOptions: {
// …
dev: !production,
cssOutputFilename: "bundle.css.map"
}
}),
// …
css({ output: 'bundle.css' }),
// …
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
// …
!production && serve(),
// …
!production && livereload('public'),
// …
production && terser()
],
watch: {
clearScreen: false
}
};
Version: Output for npm list svelte:
(node:7969) ExperimentalWarning: The fs.promises API is experimental
path/to/my/app
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
edit: I am a bit confused, because my setup also seems to ignore the bundle.css and some other things... and just when I switched back to the browser tab, everything looked as expected. The terminal output looked like this for a short moment:
────────────────── LOGS ──────────────────
[15:06:46] 200 ─ 5.94ms ─ /
[15:06:47] 200 ─ 1.80ms ─ /build/bundle.js
[15:06:47] 200 ─ 2.67ms ─ /build/bundle.js.map
[15:06:47] 404 ─ 0.13ms ─ /build/bundle.css.map
something (I did?) now created files with a "postfix"
[15:09:00] 200 ─ 0.55ms ─ /build/bundle.css?livereload=1620479340651
[15:09:44] 200 ─ 0.64ms ─ /build/bundle.css?livereload=1620479384519