Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

No CSS sourcemaps #209

Open
mustafa0x opened this issue Jan 17, 2021 · 2 comments
Open

No CSS sourcemaps #209

mustafa0x opened this issue Jan 17, 2021 · 2 comments

Comments

@mustafa0x
Copy link

CSS sourcemaps used to be emitted fine but now they're not. No instructions on how to get them back.

@gitbreaker222
Copy link

gitbreaker222 commented May 8, 2021

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/svelte@3.0.3
│ └── svelte@3.38.2 deduped
├─┬ jest-transform-svelte@2.1.1
│ └── svelte@3.38.2 deduped
├─┬ rollup-plugin-svelte@7.1.0
│ └── svelte@3.38.2 deduped
└── svelte@3.38.2 

@gitbreaker222
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants