preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

SASS not being used even when specified

Open david-potgieter opened this issue 9 years ago • 17 comments

Cannot get the CLI to initialize a new project with SASS as default.

I have tried:

  • preact create app --name dashboard --sass --dest dashboard --type full (inits with less)
  • preact create app --sass or even preact create app --sass=true (inits with css)

node -v: v6.9.0 npm -v: 3.10.8

david-potgieter avatar May 21 '17 17:05 david-potgieter

yep, I also notice this now, I believe the loader is not being identified

captura de tela 2017-05-21 as 14 22 53

the less flag works fine

I also check the package.json And I did not find the loader for sass listed, I'll check if this is what is causing the problem

vitormalencar avatar May 21 '17 17:05 vitormalencar

Yep, it seems to work fine after adding the dependencies i just wanna check with @developit to see if I'm not missing something and then I will send the PR.

vitormalencar avatar May 21 '17 18:05 vitormalencar

thanks @vitormalencar! I added the deps to a local fork and it still references css/less only. Looking forward to a PR.

Is it expected that all install types (--type) be able to init with preprocessor of choice?

david-potgieter avatar May 21 '17 18:05 david-potgieter

@david-potgieter

I changed directly the package.json that was generated inside the preact-cli folder in node_modules when I run the preact create app --sass command

Adding the loader to sass (I believe the npm link can help testing in the local fork)

And then I changed the file extension fot style.css to style.scss

I do not know if it is the plan but it I think that would be nice if the flags generate the code already with the correct extensions for each .less or .scss / sass option.

I would love to contribute to this too,

vitormalencar avatar May 21 '17 18:05 vitormalencar

I forked the repo - yarn'd the missing dependencies, rebuilt and then used the local fork to generate the app. But did not try and

And then I changed the file extension fot style.css to style.scss

Totally agreed that the CLI should most likely generate the correct file and extensions based on flags. Will see if I can get an example changed to include the correct file and extension.

david-potgieter avatar May 21 '17 18:05 david-potgieter

@david-potgieter How did you use the local fork to generate the app?

I did not test directly modifying the cli,

I added the dependencies directly in app / node_modules / preact-cli / package.json

After the app was created with the CLI.

test

vitormalencar avatar May 21 '17 19:05 vitormalencar

@vitormalencar

  • I forked the repo
  • cloned the fork into ~/path/preact-cli
  • yarn
  • made my changes to the cli
  • yarn build

then

  • node ~/path/preact-cli/lib/index.js create app --sass --type simple

Currently working on extending the examples to optionally copy *.scss/*.less/*.css across. Can share the branch with you once I push should you wish to have a look?

david-potgieter avatar May 21 '17 19:05 david-potgieter

sure! I will be glad to help 😄

vitormalencar avatar May 21 '17 19:05 vitormalencar

Great - will work more on it tomorrow. Thanks for the help so far!

david-potgieter avatar May 21 '17 20:05 david-potgieter

Ahh - yeah the --less / --sass flags actually don't affect the app generated by create at all right now. I think you guys are proposing that preact create output .css files by default but if run with -less/--sass it rename those accordingly? If so, that'd be great!

Just for clarity - .css will always just be the CSS pipeline, not sass/less. Those two are only triggered by files with the corresponding extension.

developit avatar May 23 '17 12:05 developit

@developit - yeps indeed. I am working on making sass/less/css versions of all the examples so it can deliver the correct type once specified via the cli.

david-potgieter avatar May 23 '17 12:05 david-potgieter

Yep that would be the idea,

I also saw others CLI going by another way and interpreting all css extensions like .less .sass .stylus and the build would compile anything to CSS, this would remove the necessity of the flags.

But I prefer the original idea of generating the extensions based on the CLI flags.

vitormalencar avatar May 23 '17 22:05 vitormalencar

> preact create --name test --sass
Not enough non-option arguments: got 0, need at least 1

joseluisq avatar Jun 16 '17 09:06 joseluisq

If you want to use SASS:

  1. Create an app with sass option: > preact create test --sass

  2. Rename *.less to *.scss

  3. Convert content less files to sass by using http://less2scss.awk5.com/

  4. npm start

nccnm avatar Jun 18 '17 05:06 nccnm

hey all, I tried to create an app using v1.3.0 with:

preact create appname --stylus

and got an err with a message from -h:

Optionen:
  --cwd       A directory to use instead of $PWD.                  [Standard: .]
  --name      directory and package name for the new app
  --dest      Directory to create the app within              [Standard: <name>]
  --type      A project template to start from
     [Möglichkeiten: "default", "root", "simple", "empty"] [Standard: "default"]
  --less      Pre-install LESS support               [boolean] [Standard: false]
  --sass      Pre-install SASS/SCSS support          [boolean] [Standard: false]
  --install   Install dependencies                    [boolean] [Standard: true]
  -h, --help  Hilfe anzeigen                                           [boolean]

Unbekanntes Argument: stylus
[Unknown Argument: stylus]

As following the Readme, where --stylus-option is mentioned, I assume it's not yet in the preact-cli?

vedam avatar Jul 06 '17 12:07 vedam

@vedam Stylus will be in preact-cli 1.4.0. The master branch is for development

thangngoc89 avatar Jul 06 '17 12:07 thangngoc89

In v1.4.0, default styling is set to .css and based on the arguments specified --less or --sass or --stylus you can configure the project.

PR for this - #230

reznord avatar Jul 17 '17 05:07 reznord