9

I'm currently trying to figure out how to package a couple of .scss files that we are using in a few apps into an NPM package.

I've done that previously for JS and TS libs, however I'm getting slightly confused on having packages with non-code payloads, especially because packages require an index.js entry point.

Some examples:

  • Package of styles (css/scss)
  • Package of fonts
  • Package of other non-code content

Are these valid uses of npm packages or am I thinking about it all wrong? The main reason on why I'd want it to be a package, is to have it versioned and easily installed through 'npm install package-name'.

Edit: I actually got it working okay by removing '"main": "index.js",' part of the package.json, npm installing that package of github and simply importing the scss file into my consuming application. Is this approach incorrect? What are the issues that this will cause?

Thanks!

Web Dev
  • 2,677
  • 2
  • 30
  • 41
  • 1
    Anything like this? https://stackoverflow.com/q/28283652/49478 – Anthony Aug 22 '18 at 01:51
  • 1
    Or this: https://stackoverflow.com/q/38982425/49478 – Anthony Aug 22 '18 at 01:53
  • Ooh, thanks! I'm quite new to NPM still, so just trying to figure out if I actually need to do that? E.g. I just created a folder of scss files, removed '"main": "index.js",' from package.json and then 'npm install github,.com/ into the consuming project, then simply imported that into consuming scss file like this '@import 'node_modules/my-style-lib/import.scss';'. What are the issues that this, very basic and probably incorrect approach will cause? – Web Dev Aug 22 '18 at 02:02
  • 1
    No idea. But that second answer sounds like the place to start for creating an assests/non-js-code package like what you are wanting. – Anthony Aug 22 '18 at 02:04

0 Answers0