Open rmoskal opened 4 years ago
Have you installed and configured sass?
Thanks for responding. I get this when I run node-sass -v. Does that seem right?
Now using node v13.5.0 (npm v6.13.4) rob ~ node-sass -v node-sass 4.13.1 (Wrapper) [JavaScript] libsass 3.5.4 (Sass Compiler) [C/C++] rob ~
Another piece of information I can get git@github.com:Kiho/smelte-demo.git to run fine. The setup seems quite different though.
Personally, I use dart-sass My rollup.config.js:
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import autoPreprocess from 'svelte-preprocess';
import postcss from 'rollup-plugin-postcss';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import rollup_start_dev from './rollup_start_dev';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/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/bundle.css');
},
preprocess: autoPreprocess(),
emitCss: true
}),
postcss({
extract: true,
minimize: true,
use: [
['sass', {
includePaths: [
'./node_modules',
'./node_modules/bulma',
'./src'
]
}]
]
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve({
browser: true,
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
}),
commonjs(),
// In dev mode, call `npm run start:dev` once
// the bundle has been generated
!production && rollup_start_dev,
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
Also my rollup_start_dev.js :
import * as child_process from 'child_process';
let running_dev_server = false;
export default {
writeBundle() {
if (!running_dev_server) {
running_dev_server = true;
child_process.spawn('npm', ['run', 'start:dev'], { stdio: ['ignore', 'inherit', 'inherit'], shell: true });
}
}
};
You should proceed with caution: add code block by block until you get rid of errors and you get the expected result You also probably will need to instal more npm modules. My package.json:
{
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --single --host 0.0.0.0",
"start:dev": "sirv public --single --dev --host 0.0.0.0 --port 5000"
},
"devDependencies": {
"rollup": "^1.31.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-livereload": "^1.0.4",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^2.0.6",
"rollup-plugin-svelte": "^5.1.1",
"rollup-plugin-terser": "^5.2.0",
"sass": "^1.25.0",
"svelte": "^3.18.2",
"svelte-preprocess": "^3.4.0"
},
"dependencies": {
"bulma": "^0.8.0",
"sirv-cli": "^0.4.5",
"svelma": "^0.3.2"
}
}
Good luck!
The same issue i have!
Same issue!
npm install import autoPreprocess from 'svelte-preprocess';
import autoPreprocess from 'svelte-preprocess';
for your rollup config
Also add these to the postcss()
extract: true,
minimize: true,
use: [
[
"sass",
{
includePaths: ["./node_modules", "./node_modules/bulma", "./src"],
},
],
],
Should look something like this:
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 autoPreprocess from 'svelte-preprocess';
import { terser } from "rollup-plugin-terser";
import postcss from "rollup-plugin-postcss";
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");
},
preprocess: autoPreprocess(),
emitCss: true,
}),
postcss({
extract: true,
minimize: true,
use: [
[
"sass",
{
includePaths: ["./node_modules", "./node_modules/bulma", "./src"],
},
],
],
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ["svelte"],
}),
commonjs(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require("child_process").spawn("npm", ["run", "start", "--", "--dev"], {
stdio: ["ignore", "inherit", "inherit"],
shell: true,
});
}
},
};
}
Hi, there ! In a Sapper context, following the Svelma README didn't work properly for me.. I used: { scss } from '@kazzkiq/svelte-preprocess-scss' and then I get a lot of warnings, especially from code inside Svelma components...
// root folder is /home/fe/chifoomix/site/web
/home/fe/chifoomix/site/web/node_modules/svelma/src/components /Dialog/Dialog.svelte
Dialog has unused export property 'promise'. If it is for external reference only, please consider using `export const promise`
85: // export let showClose = true
86: let resolve
87: export let promise = new Promise((fulfil) => (resolve = fulfil))
^
88:
89: // TODO: programmatic subcomponents
here's my rollup config rollup.config.txt
Any chance to get correct, complete and properly tested Installation guide for beginners?
@zoulja this thread is quite old. could you post the specific error message during usage?
@abbychau I think the issue is that with a fresh svelte setup, there is no sass support: https://github.com/sveltejs/template/blob/master/rollup.config.js yet by the looks of the above comments, sass is a requirement. It would be good for the setup guide was going from the above rollup config to a working svelma rollout config
The install leads to many errors with Svelte": "^3.0.0
, like (!) Plugin svelte: A11y: <a> element should have an href attribute
(...).
Svelte": "^3.0.0
, rollup.config.js
that works for me.
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
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';
import autoPreprocess from 'svelte-preprocess';
import postcss from 'rollup-plugin-postcss'
import preprocess from 'svelte-preprocess'
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: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production
},
preprocess: autoPreprocess(),
emitCss: true,
}),
postcss({
extract: true,
minimize: true,
use: [
[
"sass",
{
includePaths: ["./node_modules", "./node_modules/bulma", "./src"],
},
],
],
}),
//css({ output: 'bundle.css' }),
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
!production && serve(),
!production && livereload('public'),
production && terser()
],
watch: {
clearScreen: false
}
};
This is when I try to
This is the error:
This is my enviroment:
Now using node v13.5.0 (npm v6.13.4)