Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails in docker but works outside docker #99

Open
Boscop opened this issue Nov 5, 2022 · 3 comments
Open

Fails in docker but works outside docker #99

Boscop opened this issue Nov 5, 2022 · 3 comments

Comments

@Boscop
Copy link

Boscop commented Nov 5, 2022

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 :)

@thgh
Copy link
Owner

thgh commented Nov 10, 2022

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

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

@pagarazzi
Copy link

@Boscop check discord please

@Boscop
Copy link
Author

Boscop commented Nov 21, 2022

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

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

No branches or pull requests

3 participants