Skip to content

Commit

Permalink
Set up SASS .scss file compilation in Webpack config. Also set up fir…
Browse files Browse the repository at this point in the history
…st-pass SASS linter config.
  • Loading branch information
oatycreates committed Dec 31, 2016
1 parent 687b3a0 commit 7dff230
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
eslint:
enabled: true
config_file: .eslintrc
scss:
config_file: .sass-lint.yml
254 changes: 254 additions & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
# Default application configuration that all configurations inherit from.

scss_files: "**/*.scss"
plugin_directories: ['.scss-linters']

# List of gem names to load custom linters from (make sure they are already
# installed)
plugin_gems: []

# Default severity of all linters.
severity: warning

linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false

BemDepth:
enabled: false
max_elements: 1

BorderZero:
enabled: true
convention: zero # or `none`

ChainedClasses:
enabled: false

ColorKeyword:
enabled: false

ColorVariable:
enabled: true

Comment:
enabled: true
style: silent

DebugStatement:
enabled: true

DeclarationOrder:
enabled: true

DisableLinterReason:
enabled: false

DuplicateProperty:
enabled: true

ElsePlacement:
enabled: true
style: same_line # or 'new_line'

EmptyLineBetweenBlocks:
enabled: true
ignore_single_line_blocks: true

EmptyRule:
enabled: true

ExtendDirective:
enabled: false

FinalNewline:
enabled: true
present: true

HexLength:
enabled: false
style: short # or 'long'

HexNotation:
enabled: true
style: lowercase # or 'uppercase'

HexValidation:
enabled: true

IdSelector:
enabled: true

ImportantRule:
enabled: true

ImportPath:
enabled: true
leading_underscore: false
filename_extension: false

Indentation:
enabled: true
allow_non_nested_indentation: false
character: space # or 'tab'
width: 2

LeadingZero:
enabled: true
style: include_zero # or 'exclude_zero'

MergeableSelector:
enabled: true
force_nesting: true

NameFormat:
enabled: true
allow_leading_underscore: true
convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern

NestingDepth:
enabled: true
max_depth: 4
ignore_parent_selectors: false

PlaceholderInExtend:
enabled: false

PrivateNamingConvention:
enabled: false
prefix: _

PropertyCount:
enabled: true
include_nested: false
max_properties: 10

PropertySortOrder:
enabled: true
ignore_unspecified: false
min_properties: 2
separate_groups: false
order: concentric # Options: 'alphabetical', 'concentric', 'recess', 'smacss', or [array of properties], see: https://github.com/sasstools/sass-lint/blob/master/docs/rules/property-sort-order.md

PropertySpelling:
enabled: true
extra_properties: []
disabled_properties: []

PropertyUnits:
enabled: true
global: [
'ch', 'em', 'ex', 'rem', # Font-relative lengths
'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
'deg', 'grad', 'rad', 'turn', # Angle
'ms', 's', # Duration
'Hz', 'kHz', # Frequency
'dpi', 'dpcm', 'dppx', # Resolution
'%'] # Other
properties: {}

PseudoElement:
enabled: true

QualifyingElement:
enabled: true
allow_element_with_attribute: false
allow_element_with_class: false
allow_element_with_id: false

SelectorDepth:
enabled: true
max_depth: 2

SelectorFormat:
enabled: true
convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern

Shorthand:
enabled: true
allowed_shorthands: [1, 2, 3]

SingleLinePerProperty:
enabled: true
allow_single_line_rule_sets: true

SingleLinePerSelector:
enabled: true

SpaceAfterComma:
enabled: true
style: one_space # or 'no_space', or 'at_least_one_space'

SpaceAfterPropertyColon:
enabled: true
style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'

SpaceAfterPropertyName:
enabled: true

SpaceAfterVariableColon:
enabled: false
style: one_space # or 'no_space', 'at_least_one_space' or 'one_space_or_newline'

SpaceAfterVariableName:
enabled: true

SpaceAroundOperator:
enabled: true
style: one_space # or 'at_least_one_space', or 'no_space'

SpaceBeforeBrace:
enabled: true
style: space # or 'new_line'
allow_single_line_padding: false

SpaceBetweenParens:
enabled: true
spaces: 0

StringQuotes:
enabled: true
style: double_quotes # or single_quotes

TrailingSemicolon:
enabled: true

TrailingWhitespace:
enabled: true

TrailingZero:
enabled: false

TransitionAll:
enabled: false

UnnecessaryMantissa:
enabled: true

UnnecessaryParentReference:
enabled: true

UrlFormat:
enabled: true

UrlQuotes:
enabled: true

VariableForProperty:
enabled: false
properties: []

VendorPrefix:
enabled: true
identifier_list: base
additional_identifiers: []
excluded_identifiers: []

ZeroUnit:
enabled: true

Compass::*:
enabled: false
6 changes: 5 additions & 1 deletion client/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.(css|scss)$/,
/\.json$/,
/\.svg$/
],
Expand Down Expand Up @@ -141,6 +141,10 @@ module.exports = {
test: /\.css$/,
loader: 'style!css?importLoaders=1!postcss'
},
{
test: /\.scss$/,
loader: 'style!css?importLoaders=1!postcss!sass-loader'
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
{
Expand Down
12 changes: 8 additions & 4 deletions client/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
'react-native': 'react-native-web'
}
},

module: {
// First, run the linter.
// It's important to do this before Babel processes the JS.
Expand Down Expand Up @@ -115,7 +115,7 @@ module.exports = {
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.(css|scss)$/,
/\.json$/,
/\.svg$/
],
Expand All @@ -130,7 +130,7 @@ module.exports = {
test: /\.(js|jsx)$/,
include: paths.appSrc,
loader: 'babel',

},
// The notation here is somewhat confusing.
// "postcss" loader applies autoprefixer to our CSS.
Expand All @@ -149,6 +149,10 @@ module.exports = {
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1!postcss')
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1!postcss!sass-loader')
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
{
Expand All @@ -165,7 +169,7 @@ module.exports = {
}
]
},

// We use PostCSS for autoprefixing only.
postcss: function() {
return [
Expand Down
6 changes: 4 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
"http-proxy-middleware": "0.17.2",
"jest": "17.0.2",
"json-loader": "0.5.4",
"node-sass": "^4.1.1",
"object-assign": "4.1.0",
"path-exists": "2.1.0",
"postcss-loader": "1.0.0",
"promise": "7.1.1",
"react-dev-utils": "^0.4.2",
"recursive-readdir": "2.1.0",
"sass-loader": "^4.1.1",
"strip-ansi": "3.0.1",
"style-loader": "0.13.1",
"url-loader": "0.5.7",
Expand Down Expand Up @@ -72,8 +74,8 @@
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
"^.+\\.(css|scss)$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|scss|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/App/App.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import './App.scss';

import Ping from '../Ping';
import APIVersion from '../APIVersion';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$header-background-color: #222;

.App {
text-align: center;
}
Expand All @@ -8,7 +10,7 @@
}

.App-header {
background-color: #222;
background-color: $header-background-color;
height: 150px;
padding: 20px;
color: white;
Expand Down
Loading

0 comments on commit 7dff230

Please sign in to comment.