Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing next's dir option won't load compiled css file #4004

Closed
DWboutin opened this issue Mar 13, 2018 · 6 comments
Closed

Changing next's dir option won't load compiled css file #4004

DWboutin opened this issue Mar 13, 2018 · 6 comments

Comments

@DWboutin
Copy link

I changed the Next.js config to handle the structure like I wanted but, the generated css file won't load the same way.

const app = next({ dir: './src/', dev })

I load my css file like this

<link rel="stylesheet" href="/_next/static/style.css" />

When I put everything outside the src folder, like suggered, it works.

  • [x ] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

My CSS file must load the same way if I specify a dir path or not.

const app = next({ dir: './src/', dev })

Current Behavior

When I specify a dir path, Next won't load my CSS file compiled with @zeit/next-sass

Steps to Reproduce (for bugs)

  1. Change de dir option of Next.js server side
  2. Use @zeit/next-sass and import a css file into a page
  3. Add the file to an Head
  4. The file won't load

Context

I'm trying to have a cleaner structure. I'm not a fan of all the things at the root level.

Your Environment

Tech Version
next 5
node 8.10
OS OSX El Capitain V10.11.6
browser Chrome 64.0.3282.186
@haha54carol
Copy link

haha54carol commented Mar 14, 2018

Try to put your pages folder under the root not in src

--pages
--src
----index.js

@DWboutin
Copy link
Author

The pages works well, it's just the CSS file who won't load.

@timneutkens
Copy link
Member

Try upgrading to next@canary.

@timneutkens
Copy link
Member

#3722

@haha54carol
Copy link

This is my folder structure
├── ...
├── pages
├── src
│ ├── static
│ ├──── sass
│ └──── images
| ── next.config.js
└── ...

@DWboutin ,
Pages still can work but css not.
I had same issue before.
Fixed that by moving pages folder to root from src.
And you also need a next.config file
Hope it can help you!

// next.config.js
const withSass = require('@zeit/next-sass')
module.exports = withSass({
  cssModules: true,
  cssLoaderOptions: {
    importLoaders: 1,
    localIdentName: "[local]___[hash:base64:5]",
  }
})

@DWboutin
Copy link
Author

@timneutkens Works perfectly! You rock! Thanks

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants