Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

CUstom SCSS file not working

default discord avatar
jamiecee202 years ago
33

Hello,



Currently following the documentation and the guide to add this css line to the admin block of the buildconfig isn't seeming to work.


css: path.resolve(__dirname, 'relative/path/to/stylesheet.scss'),


So my payload file has as follows


export default buildConfig({
    serverURL: 'http://localhost:3000',
    admin: {
        user: Users.slug,
        css: path.resolve(__dirname, './src/assets/css.scss')
    },
  • default discord avatar
    iamroot2 years ago

    try removing the ./



    so just src/assets/css.scss



    path.resolve combines it so its probably combining to /home/./src/assets/css.scss



    instead of /home/src/assets/css.scss

  • default discord avatar
    jamiecee202 years ago

    Still isn't adding the file to the page



    So left it at src/assets/css.scss. But this is my page structure



    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <script defer src="/admin/main.js"></script></head>
    
    <body>
      <div id="app"></div>
      <div id="portal"></div>
    </body>
    
    </html>
  • default discord avatar
    iamroot2 years ago

    oh i forgot config file is within src, try just doing assets/css.scss

  • default discord avatar
    jamiecee202 years ago

    Still nothing, hmm.


    THe directory and file are present in the src folder also so they defo exist



    import { buildConfig } from 'payload/config';
    import path from 'path';
    // import Examples from './collections/Examples';
    import Users from './collections/Users';
    
    export default buildConfig({
      serverURL: 'http://localhost:3000',
      admin: {
        user: Users.slug,
        css: path.resolve(__dirname, 'assets/app.scss'),
      },
      collections: [
        Users,
        // Add Collections here
        // Examples,
      ],
      typescript: {
        outputFile: path.resolve(__dirname, 'payload-types.ts'),
      },
      graphQL: {
        schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
      },
    });


    This is the full payload.config.ts



    Then this is the file structure

  • default discord avatar
    iamroot2 years ago

    if you do yarn build does the scss file show up in dist?

  • default discord avatar
    jamiecee202 years ago

    yeah

  • default discord avatar
    iamroot2 years ago

    what are you doing to check if hte scss file is working?

  • default discord avatar
    jamiecee202 years ago

    Just some simple css to modify colours on the page.



    Trying to modify the colour of the class on the breadcrumbs span

  • default discord avatar
    iamroot2 years ago

    if you look in chrome dev console are you able to see if they styles just got overridden or smth?

  • default discord avatar
    jamiecee202 years ago

    Doesn't pick up any styling I've added. Only references the index.scss which assuming is just the default

  • default discord avatar
    iamroot2 years ago

    well it probably gets compiled into 1 css file with webpack

  • default discord avatar
    jamiecee202 years ago

    That would make sense, but just isn't picking it up

  • default discord avatar
    iamroot2 years ago

    not able to reproduce it





      admin: {
        user: Users.slug,
        css: path.join(__dirname, 'assets/styles.scss'),
      },
  • default discord avatar
    jamiecee202 years ago

    This is very strange

  • default discord avatar
    iamroot2 years ago

    ya like it should just work

  • default discord avatar
    jamiecee202 years ago

    Ive created the blank typescript template from npx create-payload-app so nothing I've done thats different

  • default discord avatar
    iamroot2 years ago

    whats in your app.scss

  • default discord avatar
    jamiecee202 years ago

    Ive changed the name and input to match what you used, so body background red and filename styles

  • default discord avatar
    iamroot2 years ago

    try incognito?



    maybe its an extension



    or cache

  • default discord avatar
    jamiecee202 years ago

    Nope, not cached



    I be confusion

  • default discord avatar
    iamroot2 years ago

    ya not a clue, what os are you on?

  • default discord avatar
    jamiecee202 years ago

    linux

  • default discord avatar
    iamroot2 years ago

    maybe try a backslash? your using path so it shouldn't matter but we looking at longshots here

  • default discord avatar
    jamiecee202 years ago

    backslash breaks the string

  • default discord avatar
    iamroot2 years ago

    you would need a double backslash so

    assets\\styles.scss
  • default discord avatar
    jamiecee202 years ago

    Nope :/

  • default discord avatar
    iamroot2 years ago

    ya not sure



    could you send me your styles.scss

  • default discord avatar
    jamiecee202 years ago

    Got it working on a different project, so wonder if setup with the cli has something that I've missed?



    A fellow colleague has re-created it.



    So with npx create-payload-app, setup a blank typescript project then attempt it, it doesnt work

  • default discord avatar
    iamroot2 years ago

    really?



    all i did was

    npx create-payload-app

    spammed enter added styles.scss and the admin config and it worked



    what node version?

  • default discord avatar
    jamiecee202 years ago

    16.13.1



    and npx v9.1.2



    So turns out caching does work for blank projects, must just be a one off bug

  • default discord avatar
    digimortal_2 years ago

    I just hit this same issue. What did you do to resolve it

    @196034894760116224

    ? I'm running Payload inside a Docker container, so I'm not sure if there's something else going on there.



    Running the project outside of Docker seems to work fine



    Ah, docker is running

    serve

    instead of

    dev
  • default discord avatar
    johnmadrigal_2 years ago

    Just reinstall your node_modules

  • default discord avatar
    thgh.2 years ago

    More specifically:


    rm -Rf node_modules/.cache
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.