8000 Example how to compile scss? · Issue #82 · c9s/c6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Example how to compile scss? #82

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

Closed
tboerger opened this issue Sep 10, 2015 · 10 comments
Closed

Example how to compile scss? #82

tboerger opened this issue Sep 10, 2015 · 10 comments

Comments

@tboerger
Copy link

Can you provide a simple example how to compile scss? Than I can create a PR for the cli tool.

@tboerger
Copy link
Author

No comment? :(

@c9s
Copy link
Owner
c9s commented Sep 17, 2015

Hi Thomas,

The compile method is not implemented yet

Thomas Boerger notifications@github.com 於 2015年9月17日 星期四寫道:

No comment? :(


Reply to this email directly or view it on GitHub
#82 (comment).

@tboerger
8000 Copy link
Author

@c9s I know, already commented that on #80 (comment), because of that I'm asking for an example how the library works for creating a pull request to get the cli tool working. Or is the library overall not able to build css from scss?

@c9s
Copy link
Owner
c9s commented Sep 18, 2015

probably #66 #66 (comment)

we discussed the interface of the Compile method. however I think the first step is to make CompileDeclaration work

@c9s
Copy link
Owner
c9s commented Sep 18, 2015

There are some tests you can check out: https://github.com/c9s/c6/blob/master/compiler/compact_compiler_test.go

@c9s
Copy link
Owner
c9s commented Sep 18, 2015

Or is the library overall not able to build css from scss?

yes, it's not done yet.

@tboerger
Copy link
Author

Yeah, looks like it's really not working yet... I tried to build this:

package main

import (
    "fmt"
    "io/ioutil"
    "log"
    "os"
    "path/filepath"

    "github.com/spf13/cobra"

    "github.com/c9s/c6/compiler"
    "github.com/c9s/c6/parser"
    "github.com/c9s/c6/runtime"
)

func main() {
    var rootCmd = &cobra.Command{
        Use:   "c6",
        Short: "C6 is a very fast SASS compatible compiler",
        Long:  `C6 is a SASS compatible implementation written in Go.`,
        Run: func(cmd *cobra.Command, args []string) {

        },
    }

    var versionCmd = &cobra.Command{
        Use:   "version",
        Short: "Print the version number of C6",
        Long:  `All software has versions. This is C6's`,
        Run: func(cmd *cobra.Command, args []string) {
            fmt.Println("C6 SASS Compiler v0.1 -- HEAD")
        },
    }

    var compileCmd = &cobra.Command{
        Use:   "compile <input> <output>",
        Short: "Compile some SCSS files",
        Long:  `Compile SCSS files into CSS files`,
        Run: func(cmd *cobra.Command, args []string) {
            if len(args) != 2 {
                log.Fatalf("Please provide input and output paths")
            }

            input := args[0]
            output := args[1]

            if _, err := os.Stat(input); os.IsNotExist(err) {
                log.Fatalf("Input file does not exist or is unreadable")
            }

            path := filepath.Dir(output)

            if _, err := os.Stat(path); os.IsNotExist(err) {
                log.Fatalf("Output dir does not exist or is unreadable")
            }

            context := runtime.NewContext()
            parser := parser.NewParser(context)
            compile := compiler.NewCompactCompiler(context)

            f, err := os.OpenFile(
                output,
                os.O_CREATE|os.O_RDWR|os.O_TRUNC,
                0660)

            defer f.Close()

            if err != nil {
                log.Fatalf("Failed to open output file for writing")
            }

            source, err := ioutil.ReadFile(input)

            if err != nil {
                log.Fatalf("Failed to read source from input file")
            }

            stmts := parser.ParseScss(string(source[:]))
            result := compile.CompileString(stmts)

            fmt.Println(result)
        },
    }

    rootCmd.AddCommand(versionCmd)
    rootCmd.AddCommand(compileCmd)
    rootCmd.Execute()
}

@tboerger
Copy link
Author

Sad, still no progress? I wish we have a scss and coffeescript compiler in golang :(

@c9s
Copy link
Owner
c9s commented Oct 16, 2015

Too busy to work on this, I have to earn money, sorry.

@tboerger
Copy link
Author

Closed as there seem to be no activity anymore.

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

2 participants
0