Skip to content

Commit bb35ab7

Browse files
committed
better tracking of SASS_STYLE
1 parent 457864b commit bb35ab7

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/cache.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const debug = require('debug')('canvas_css')
22
import _ from 'lodash'
33
import {readJsonSync} from './utils'
4-
import {paths as PATHS} from "./config"
4+
import {paths as PATHS} from './config'
5+
import SASS_STYLE from './sass_style'
56
const outputJson = require('bluebird').promisify(require('fs-extra').outputJson)
67

78
const caches = ['file_checksums', 'bundles_with_deps']
@@ -15,7 +16,7 @@ let cache = {
1516
function initCache(name) {
1617
const filename = PATHS[name]
1718
let self = {
18-
data: readJsonSync(filename),
19+
data: readJsonSync(filename + SASS_STYLE),
1920
isSaved: false,
2021

2122
update(key, value) {

src/compile-bundle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import autoprefixer from 'autoprefixer'
1111
import postcssUrl from 'postcss-url'
1212
import {paths as PATHS} from "./config"
1313
import {BRANDABLE_VARIANTS} from './variants'
14+
import SASS_STYLE from './sass_style'
1415
import {fileChecksumSync} from './checksum'
1516
import supportedBrowsers from './browser-support'
1617
import cache from './cache'
@@ -71,9 +72,8 @@ export default async function compileSingleBundle ({bundleName, variant, brandId
7172
const nodeSassResult = await sassRender({
7273
file: sassFile,
7374
includePaths: includePaths,
74-
// if you want compressed output (eg: in production), set the environment variable CANVAS_SASS_STYLE=compressed
75-
outputStyle: process.env.CANVAS_SASS_STYLE || 'nested',
76-
sourceComments: process.env.CANVAS_SASS_STYLE !== 'compressed',
75+
outputStyle: SASS_STYLE,
76+
sourceComments: SASS_STYLE !== 'compressed',
7777
sourceMap: false
7878
})
7979

src/sass_style.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// If you want compressed output (eg: in production), set the environment
2+
// variable SASS_STYLE=compressed. For rails apps, we'll fall back to a sane
3+
// default of using "compressed" if RAILS_ENV == production
4+
export default const SASS_STYLE = process.env.SASS_STYLE ||
5+
(process.env.RAILS_ENV == 'production' ? 'compressed' : 'nested')
6+

0 commit comments

Comments
 (0)