Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Initial commit of basic version
Browse files Browse the repository at this point in the history
[changelog]
added: basic transform process
added: README with setup instructions
  • Loading branch information
OldhamMade committed Jan 30, 2021
0 parents commit edc62f3
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
154 changes: 154 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
### https://raw.github.com/github/gitignore/2a4de265d37eca626309d8e115218d18985b5435/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### https://raw.github.com/github/gitignore/2a4de265d37eca626309d8e115218d18985b5435/Global/Emacs.gitignore

# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

# network security
/network-security.data



### https://raw.github.com/github/gitignore/2a4de265d37eca626309d8e115218d18985b5435/Erlang.gitignore

.eunit
*.o
*.beam
*.plt
erl_crash.dump
.concrete/DEV_MODE

# rebar 2.x
.rebar
rel/example_project
ebin/*.beam
deps

# rebar 3
.rebar3
_build/
_checkouts/


### https://raw.github.com/github/gitignore/2a4de265d37eca626309d8e115218d18985b5435/Elixir.gitignore

/_build
/cover
/deps
/doc
/.fetch
erl_crash.dump
*.ez
*.beam
/config/*.secret.exs
.elixir_ls/


### https://raw.github.com/github/gitignore/2a4de265d37eca626309d8e115218d18985b5435/Sass.gitignore

.sass-cache/
*.css.map
*.sass.map
*.scss.map


### Local rules

# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
phoenix_sass-*.tar

# Elixir Language Server
.elixir_ls
Expand Down
112 changes: 112 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Sass compiler for Phoenix

This library compiles Sass (`.scss` and `.sass`) files to CSS
within Phoenix projects.

## Installation

1. Add `phoenix_sass` to your list of dependencies in `mix.exs`:

```diff
defp deps do
[
{:phoenix, "~> 1.5.1"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sql, "~> 3.4"},
{:postgrex, ">= 0.0.0"},
{:phoenix_live_view, "~> 0.12.0"},
{:floki, ">= 0.0.0", only: :test},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_dashboard, "~> 0.2.0"},
{:telemetry_metrics, "~> 0.4"},
{:telemetry_poller, "~> 0.4"},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
- {:plug_cowboy, "~> 2.0"}
+ {:plug_cowboy, "~> 2.0"},
+ {:phoenix_sass, "~> 0.1.0"}
]
end
```

1. Add the `:phoenix_sass` compiler to your Mix compilers so your backends
are recompiled when Saas files change:

```diff
def project do
[
app: :your_app,
version: "0.1.0",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
- compilers: [:phoenix, :gettext] ++ Mix.compilers(),
+ compilers: [:phoenix, :gettext] ++ Mix.compilers() ++ [:phoenix_sass],
start_permanent: Mix.env() == :prod,
releases: releases(),
aliases: aliases(),
deps: deps()
]
end
```

1. Add `phoenix_sass` to your list of reloadable compilers in `config/dev.exs`:

```diff
config :your_app, YourAppWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
+ reloadable_compilers: [:gettext, :phoenix, :elixir, :phoenix_sass],
watchers: [
```

1. Add your Sass dir to the live reload patterns in `config/dev.exs`, for example:

```diff
config :your_app, YourAppWeb.Endpoint,
live_reload: [
patterns: [
+ ~r"priv/sass/.*(sass|scss)$",
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
```

1. And finally, in `config/prod.exs` (or `config/releases.exs`) define your options:

```diff
+ config :your_app, :phoenix_sass,
+ pattern: "priv/sass/**/*.s[ac]ss", # this is the default
+ output_dir: "priv/static/css", # this is the default
+ output_style: 3 # this is the default (compressed)
```


## Config

Config is pretty simple. `:pattern` can be a string or a list of
strings defining paths to search for Sass files.

All paths (`pattern` and `output_dir`) are relative to `Application.app_dir/1`.

Any further options are passed directly through to [`sass_compiler`][sass_compiler_opts]
along with `output_style`.


## Usage

Simply add Sass files to `priv/sass` and edit them as needed. They'll
be converted to CSS on save, and Phoenix's LiveReload will take care
of the rest.

Any Sass file prefixed with an underscore (for example, a file named
`_colors.scss`) will be skipped during processing, but should be handled
correctly as an include file (for a file named `app.scss`, for example).


## Why? (Motivation)

One should be able to use Sass for a website without the need for Webpack.


[sass_compiler_opts]: https://hexdocs.pm/sass_compiler/Sass.html#module-currently-supported-sass-options
Loading

0 comments on commit edc62f3

Please sign in to comment.