From 0650935b4e22365628ca60ccebe65db0486b6c62 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Fri, 12 Aug 2016 13:31:55 -0700 Subject: [PATCH 1/3] Add sass support Works with hot loading. --- packages/react-server-cli/package.json | 4 +++- packages/react-server-cli/src/compileClient.js | 5 +++++ packages/react-server-cli/src/index.js | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-server-cli/package.json b/packages/react-server-cli/package.json index a5f9dcb5c..5c4bcc1da 100644 --- a/packages/react-server-cli/package.json +++ b/packages/react-server-cli/package.json @@ -44,7 +44,9 @@ "yargs": "~3.15.0" }, "devDependencies": { + "node-sass": "^3.8.0", "nsp": "^2.4.0", - "rimraf": "^2.5.2" + "rimraf": "^2.5.2", + "sass-loader": "^4.0.0" } } diff --git a/packages/react-server-cli/src/compileClient.js b/packages/react-server-cli/src/compileClient.js index c0d0f51f4..142e3bddf 100644 --- a/packages/react-server-cli/src/compileClient.js +++ b/packages/react-server-cli/src/compileClient.js @@ -163,6 +163,11 @@ const packageCodeForBrowser = (entrypoints, outputDir, outputUrl, hot, minify, l loader: extractTextLoader + "!less-loader", exclude: /node_modules/, }, + { + test: /\.scss$/, + loader: extractTextLoader + "!sass-loader", + exclude: /node_modules/, + }, { test: /\.md/, loader: "raw", diff --git a/packages/react-server-cli/src/index.js b/packages/react-server-cli/src/index.js index 01565a58b..4ef815bef 100644 --- a/packages/react-server-cli/src/index.js +++ b/packages/react-server-cli/src/index.js @@ -4,6 +4,7 @@ const parseCliArgs = require("./parseCliArgs").default; require.extensions['.css'] = require.extensions['.less'] = +require.extensions['.scss'] = function(module, filename) { return module._compile("", filename); }; From 337878e90f662bf07142ee4fd74da33278e10410 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Fri, 12 Aug 2016 13:49:47 -0700 Subject: [PATCH 2/3] Add a test page for SASS support --- packages/react-server-test-pages/entrypoints.js | 4 ++++ packages/react-server-test-pages/pages/styles/sass.js | 9 +++++++++ packages/react-server-test-pages/pages/styles/sass.scss | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 packages/react-server-test-pages/pages/styles/sass.js create mode 100644 packages/react-server-test-pages/pages/styles/sass.scss diff --git a/packages/react-server-test-pages/entrypoints.js b/packages/react-server-test-pages/entrypoints.js index 23800d691..15c6236c7 100644 --- a/packages/react-server-test-pages/entrypoints.js +++ b/packages/react-server-test-pages/entrypoints.js @@ -33,6 +33,10 @@ module.exports = { entry: "/styles/promises", description: "Stylesheets returned from promises", }, + Sass: { + entry: "/styles/sass", + description: "SASS styles", + }, NavigationDataBundleCache: { entry: "/navigation/data-bundle-cache", description: "Data bundle cache", diff --git a/packages/react-server-test-pages/pages/styles/sass.js b/packages/react-server-test-pages/pages/styles/sass.js new file mode 100644 index 000000000..4f776cd59 --- /dev/null +++ b/packages/react-server-test-pages/pages/styles/sass.js @@ -0,0 +1,9 @@ +import "./sass.scss" + +const RedThing = () =>
This should be red
+ +export default class SassPage { + getElements() { + return + } +} diff --git a/packages/react-server-test-pages/pages/styles/sass.scss b/packages/react-server-test-pages/pages/styles/sass.scss new file mode 100644 index 000000000..c1ffb7894 --- /dev/null +++ b/packages/react-server-test-pages/pages/styles/sass.scss @@ -0,0 +1,5 @@ +$reddish: red; + +.red-thing { + background-color: $reddish; +} From 0df92ff6bbe18cc892ad55fb54d47ed17835b951 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Fri, 12 Aug 2016 14:13:09 -0700 Subject: [PATCH 3/3] Oops, node-sass and sass-loader should be normal deps --- packages/react-server-cli/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-server-cli/package.json b/packages/react-server-cli/package.json index 5c4bcc1da..10ab677da 100644 --- a/packages/react-server-cli/package.json +++ b/packages/react-server-cli/package.json @@ -31,12 +31,14 @@ "lodash": "^4.14.1", "mkdirp": "~0.5.1", "node-libs-browser": "~0.5.2", + "node-sass": "^3.8.0", "null-loader": "~0.1.1", "pem": "^1.8.1", "q": "~1.4.1", "raw-loader": "^0.5.1", "react-hot-loader": "~1.3.0", "react-server-core-middleware": "^0.4.1", + "sass-loader": "^4.0.0", "style-loader": "~0.12.3", "webpack": "^1.13.1", "webpack-dev-server": "~1.13.0", @@ -44,9 +46,7 @@ "yargs": "~3.15.0" }, "devDependencies": { - "node-sass": "^3.8.0", "nsp": "^2.4.0", - "rimraf": "^2.5.2", - "sass-loader": "^4.0.0" + "rimraf": "^2.5.2" } }