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

Unable to import CSS file from node_modules when target is electron #1868

Closed
drakang4 opened this issue Aug 8, 2018 · 3 comments
Closed
Labels
🐛 Bug CSS Preprocessing All the PostCSS, Less, SASS, etc issues Electron

Comments

@drakang4
Copy link

drakang4 commented Aug 8, 2018

🐛 bug report

I cannot import CSS from node_modules when the target of parcel bundler is electron.

🎛 Configuration (.babelrc, package.json, cli command)

// tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "lib": [
      "dom",
      "es2015",
      "es2016",
      "es2017",
    ],
    "sourceMap": true,
    "noImplicitReturns": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "jsx": "react",
    "pretty": true,
    "rootDir": ".",
    "outDir": "build"
  },
  "exclude": [
    "node_modules"
  ]
}
// run command
parcel app/index.html --target electron --out-dir build/app --public-url .

🤔 Expected Behavior

Apply styles without any error.

😯 Current Behavior

image

Cannot import CSS

💁 Possible Solution

I don't have any idea 😥

🔦 Context

I don't have any problem when the target is browser
I found that importing CSS file as relative path is working, but it doesn't work when I import CSS from node_modules as absolute path when the target is electron. parcel build has the same issue not only serve.

💻 Code Sample

I created a sample repository that makes the same error of this issue. https://github.com/drakang4/parcel-electron-css-bug

🌍 Your Environment

Software Version(s)
Parcel 1.9.7
Node 8.11.3
npm/Yarn 5.4.2 / 1.9.2
Operating System Windows 10
@cousinbenson
Copy link

hi, I've found a quick fix is to import the css like this:

import '../../node_modules/normalize/normalize.css'

I don't like writing it this way though, and would appreciate a fix.

Thanks!

@devongovett devongovett added CSS Preprocessing All the PostCSS, Less, SASS, etc issues Electron labels Jan 6, 2019
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
@cuberoot
Copy link

I hit this while trying to bring in a library that contains .css files. I had to switch back to target: 'browser' because I don't have control over the source.

In order to access the electron package, I did this:

const { ipcRenderer } = window.require('electron')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug CSS Preprocessing All the PostCSS, Less, SASS, etc issues Electron
Projects
None yet
Development

No branches or pull requests

5 participants