Skip to content

Commit

Permalink
Merge pull request #28 from larrybotha/refactor/entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
larrybotha authored Nov 9, 2021
2 parents 14e22e8 + f5d41b1 commit b69c2be
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 41 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"commit": "git-cz",
"clean": "rm -rf build && mkdir build",
"prebuild": "npm run clean",
"build": "sass scss/style.scss --load-path=node_modules/normalize.css > build/style.css",
"build": "npm run build:style && npm run build:global",
"build:global": "sass scss/global-only.scss --load-path=node_modules/normalize.css > build/style.css",
"build:style": "sass scss/style.scss --load-path=node_modules/normalize.css > build/style.css",
"build:watch": "nodemon -e scss --exec 'npm run build'",
"test": "jest",
"test:watch": "npm test -- --watch",
Expand Down
11 changes: 11 additions & 0 deletions scss/_reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*------------------------------------*\
RESET STYLES
\*------------------------------------*/
/**
* Import resets
*
* normalize.css requires `includePaths: ['node_modules/normalize.css']` in
* your Sass config
*/
@import "normalize";
@import "core/reset";
10 changes: 0 additions & 10 deletions scss/_support.scss

This file was deleted.

19 changes: 14 additions & 5 deletions scss/custom/_index.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/*------------------------------------*\
CUSTOM STYLES
\*------------------------------------*/
// order matters
@import "functions/index";
@import "mixins/index";
@import "global/index";
@import "app/index";
/**
* Import custom variables, mixins, and functions
*/
@import "support";

/**
* Import custom global styles
*/
@import "global";

/**
* Import custom styles
*/
@import "app";
10 changes: 10 additions & 0 deletions scss/custom/_support.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*------------------------------------*\
CUSTOM SUPPORT SCSS
\*------------------------------------*/
/**
* This file should be imported after any core support files to ensure
* that variables, mixins, and functions defined here override core
* equivalents
*/
@import "variables";
@import "tools";
20 changes: 9 additions & 11 deletions scss/global.scss → scss/global-only.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@charset "UTF-8";

/*------------------------------------*\
GLOBAL STYLES
GLOBAL ONLY STYLES ENTRYPOINT
\*------------------------------------*/
/**
* Import only global styles
Expand All @@ -15,20 +15,18 @@
*/

/**
* import functions and mixins
* Import resets
*/
@import "support";
@import "reset";

/**
* Import resets
*
* normalize.css requires `includePaths: ['node_modules/normalize.css']` in your Sass config
* Import functions and mixins
*/
@import "normalize";
@import "core/reset";
@import "core/support";
@import "custom/support";

/**
* import global styles
* Import global styles
*/
@import "core/global/index";
@import "custom/global/index";
@import "core/global";
@import "custom/global";
28 changes: 18 additions & 10 deletions scss/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
@charset "UTF-8";

/*------------------------------------*\
STYLES ENTRYPOINT
\*------------------------------------*/
/**
* Import everything:
*
* - tools
* - global styles
* - app styles
*
* This will be the most common entry point for your app's styles.
* Import resets
*/
@import "support";
@import "global";
@import "custom/app/index";
@import "reset";

/**
* Import core support files and globals
*/
@import "core/support";
@import "core/global";

/**
* Import custom styles to override core
*/
@import "custom";
6 changes: 3 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const path = require("path");

const options = {
...require("./options"),
file: path.resolve(__dirname, "../scss/global.scss"),
file: path.resolve(__dirname, "../scss/global-only.scss"),
};
const entryPoints = [
"style.scss",
"global.scss",
"_support.scss",
"global-only.scss",
"_reset.scss",
"core/_global.scss",
"core/_support.scss",
"core/_reset.scss",
Expand Down
2 changes: 1 addition & 1 deletion test/options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("path");

module.exports = {
file: path.resolve(__dirname, "../scss/global.scss"),
file: path.resolve(__dirname, "../scss/global-only.scss"),
includePaths: ["node_modules/normalize.css"],
};

0 comments on commit b69c2be

Please sign in to comment.