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

Using css-modules in meteor package #41

Open
helitack opened this issue May 25, 2016 · 13 comments
Open

Using css-modules in meteor package #41

helitack opened this issue May 25, 2016 · 13 comments

Comments

@helitack
Copy link

helitack commented May 25, 2016

When using css modules in a package:

myapp/packages/mypackage/package.js

Package.describe({
  name: 'me:mypackage',
});
Package.onUse(function(api) {
  api.versionsFrom('1.3.2.4');
  api.use('ecmascript');
  api.use('nathantreid:css-modules');

  api.mainModule('mypackage.js');
});

Where is it getting it's package options from? the root project's package.json file? Could it be possible to define different package options such as extensions or ignorePaths that apply only to the package?

@akanix42
Copy link
Owner

The options are pulled from the project's package.json file. The Meteor build process does supply the ability to detect when it is being run in a package, so I'd need introduce a new setting (probably packageOptions: { yourPackage: { someSetting: true; } }.
I'm thinking it would merge your package-specific settings with your global settings so you would only need to specify the settings that are different.
How does that sound?

@helitack
Copy link
Author

helitack commented Jul 29, 2016

That sounds great! I assume that would all be in the app's package.json file?
It would be nice to keep config for a package inside of the package itself in case the package is used in multiple apps. Is it possible to stick the packageOptions for a specific package somewhere in the package? perhaps a package.json file or preferably, right in the package.js file?

@akanix42
Copy link
Owner

From what I know of package.js, the answer is no, but handling a package.json file inside the package should be doable.

If no css modules config is found inside the package, should it default to the default options or to the options specified in the app's package.json? I'm currently leaning strongly towards the latter, since all the package author would have to is define the following in order to prevent that:

"cssModules": {}

@helitack
Copy link
Author

I thought the package.js would be a reach. package.json is just as good.

I fully agree, I like your idea of merging the two as you mentioned above. I feel it would be excess config to do otherwise, and if it's easy enough to prevent with "cssModules": {} as you mentioned, then it should be totally fine.

Big +1.

@hisayan
Copy link
Contributor

hisayan commented Jul 29, 2016

I try to make my own package with 'nathantreid:css-modules'.

$ meteor add my:package

 => Errors while adding packages:             

While determining active plugins:
error: conflict: two packages included in my:package (nathantreid:css-modules and meteor) are both trying to handle *.css

While determining active plugins:
error: conflict: two packages included in my:package (nathantreid:css-modules and meteor) are both trying to handle *.css

What should I do to use css-modules in own package ?

@akanix42
Copy link
Owner

@hisayan I'll publish the fix for that error later today.

@akanix42
Copy link
Owner

@hisayan you should be good now with v2.2.1.

@hisayan
Copy link
Contributor

hisayan commented Jul 30, 2016

Thanks. It was solved.

@hisayan
Copy link
Contributor

hisayan commented Aug 3, 2016

I have a problem.

It is ok that the css file in my own package. thanks.
but the css file in npm_modules in my own package doesn't work well.

This is my simple sample code.
https://github.com/hisayan/rfgtest

$ git clone https://github.com/hisayan/rfgtest.git
$ meteor

it works fine.

but interrupt this process ([ctrl]+c) and restart.

$ meteor

The css file 'flexboxgrid' in node_modules in my package is not load with your css-loader.
The css file is imported as a plane text.

but

$ meteor reset
$ meteor

It works fine.

Is there any mistake in my code ?
or some problem in my environment ?

and I want to use react-flexbox-grid in my own package finally.
https://github.com/roylee0704/react-flexbox-grid

@akanix42
Copy link
Owner

akanix42 commented Aug 5, 2016

@hisayan I should have time to look at that this weekend.

@akanix42
Copy link
Owner

akanix42 commented Aug 7, 2016

@hisayan This may be due to the way Meteor is hardcoding CSS support. in npm packages. I'll do some more digging but right now it's not looking too good until Meteor opens up the .css extension.

@hisayan
Copy link
Contributor

hisayan commented Aug 8, 2016

I appreciate it.
I pick up the CSS file from npm package and use it outside of npm package for now.

@PolGuixe
Copy link

Is this related to why this package is not working in Meteor? https://github.com/roylee0704/react-flexbox-grid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants