rollup-plugin-scss icon indicating copy to clipboard operation
rollup-plugin-scss copied to clipboard

Fails in docker but works outside docker

Open Boscop opened this issue 3 years ago • 3 comments

Hi, thanks for this great plugin :) It works great for me, but unfortunately only outside docker: My docker image for my web app builds fine when my frontend doesn't import any scss file, but it needs a single scss file (index.scss), and when the frontend imports it, yarn build fails with this error:

#29 469.0 [!] RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript) #29 469.0 ../../index.scss (1:5) #29 469.0 1: html { #29 469.0 ^

In the Dockerfile I'm doing yarn install before yarn build and I have "rollup-plugin-scss": "^3.0.0", in my devDependencies, so it should work, right? Here I posted my Dockerfile, package.json and rollup.config.mjs file for context: https://gist.github.com/Boscop/67fe407a634ee6dcf9f55abfe4328f45 E.g. this is the rollup.config.mjs file:

import rust from "@wasm-tool/rollup-plugin-rust";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import copy from "rollup-plugin-copy";
import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import scss from "rollup-plugin-scss"
import dev from "rollup-plugin-dev"
import nodePolyfills from "rollup-plugin-polyfill-node";

const is_watch = !!process.env.ROLLUP_WATCH;

export default {
	input: {
		index: "Cargo.toml",
	},
	output: {
		dir: "dist/js", 
		format: "iife",
		sourcemap: true,
	},
	plugins: [
		nodeResolve(),
		is_watch && dev({
			dirs: ["dist"],
			host: "0.0.0.0", 
			port: 8080,
			proxy: [
				{ from: "/api", to: "http://localhost:9000/api" },
			],
		}),
		scss({
			output: "dist/bundle.css",
			verbose: true,
			failOnError: true,
		}),
		rust({
			serverPath: "js/", 
		}),
		commonjs(),
		nodePolyfills(),
		copy({
			targets: [
				{ src: "index.html", dest: "dist" },
				{ src: "favicon.png", dest: "dist" },
			]
		}),
		is_watch && livereload("dist"),
		!is_watch && terser(),
	],
};

Btw, outside of docker (on Windows 10), yarn build works fine, even when my project imports the scss file! So I'm wondering, why is it only failing inside docker?

It seems I'm stuck with this, so I'd really appreciate any hint for how to solve this :)

Boscop avatar Nov 05 '22 23:11 Boscop

No idea about what's going wrong. Which node version are you using on Windows?

Cargo.toml as input, have never seen that. Interesting

thgh avatar Nov 10 '22 01:11 thgh

@Boscop check discord please

pagarazzi avatar Nov 21 '22 08:11 pagarazzi

@thgh I'm using node v18.12.0 The Cargo.toml as input is processed by @wasm-tool/rollup-plugin-rust.

Boscop avatar Nov 21 '22 11:11 Boscop