Skip to content

Commit

Permalink
feat: allows for adding custom CSS in addition to SCSS overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Dec 29, 2020
1 parent c84bcde commit 544a4db
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 1 addition & 3 deletions demo/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default buildConfig({
// // favicon: '/img/whatever.png',
// },
disable: false,
scss: path.resolve(__dirname, './client/scss/overrides.scss'),
components: {
// Nav: () => (
// <div>Hello</div>
Expand Down Expand Up @@ -101,9 +102,6 @@ export default buildConfig({
graphQLPlayground: '/graphql-playground',
},
defaultDepth: 2,
paths: {
scss: path.resolve(__dirname, './client/scss/overrides.scss'),
},
graphQL: {
maxComplexity: 1000,
mutations: {}, // TODO: needs typing
Expand Down
2 changes: 2 additions & 0 deletions src/admin/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ dialog {
.payload__modal-item--enterDone {
z-index: $z-modal;
}

@import '~payload-user-css';
1 change: 1 addition & 0 deletions src/admin/scss/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Used as a placeholder for when the Payload app does not have custom CSS */
1 change: 1 addition & 0 deletions src/admin/scss/overrides.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Used as a placeholder for when the Payload app does not have custom SCSS */
5 changes: 2 additions & 3 deletions src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const defaults = {
disable: false,
indexHTML: path.resolve(__dirname, '../admin/index.html'),
components: {},
css: path.resolve(__dirname, '../admin/scss/custom.css'),
scss: path.resolve(__dirname, '../admin/scss/overrides.scss'),
},
upload: {},
email: {
Expand Down Expand Up @@ -44,7 +46,4 @@ export const defaults = {
},
hooks: {},
localization: false,
paths: {
scss: path.resolve(__dirname, '../admin/scss/overrides.scss'),
},
};
8 changes: 2 additions & 6 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default joi.object({
}),
disable: joi.bool(),
indexHTML: joi.string(),
css: joi.string(),
scss: joi.string(),
components: joi.object()
.keys({
Nav: component,
Expand Down Expand Up @@ -109,10 +111,4 @@ export default joi.object({
hooks: joi.object().keys({
afterError: joi.func(),
}),
paths: joi.object()
.keys({
configDir: joi.string(),
config: joi.string(),
scss: joi.string(),
}),
});
2 changes: 2 additions & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export type PayloadConfig = {
}
disable?: boolean;
indexHTML?: string;
css?: string
scss?: string
components?: {
Nav?: React.ComponentType
Account?: React.ComponentType
Expand Down
3 changes: 2 additions & 1 deletion src/webpack/getBaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default (config: Config): Configuration => ({
alias: {
'payload/config': config.paths.config,
'@payloadcms/payload$': mockModulePath,
'payload-scss-overrides': config.paths.scss,
'payload-user-css': config.admin.css,
'payload-scss-overrides': config.admin.scss,
dotenv: mockDotENVPath,
},
extensions: ['.ts', '.tsx', '.js', '.json'],
Expand Down

0 comments on commit 544a4db

Please sign in to comment.