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

Support javascript entry file #8

Closed
CyberAP opened this issue Dec 12, 2018 · 2 comments
Closed

Support javascript entry file #8

CyberAP opened this issue Dec 12, 2018 · 2 comments

Comments

@CyberAP
Copy link
Contributor

CyberAP commented Dec 12, 2018

I am building my css bundle using webpack's require.context.

Config

    entry: {
      app: './entries/application.js',
      styles: './entries/styles.js'
    },

styles.js

require.context('../css', false, /\.css$/);
require.context('../components', true, /\.css$/);
require.context('../pages', true, /\.css$/);

It would be super awesome to have this plugin working for js entries as well.

@fqborges
Copy link
Owner

Hello! Let me see if I understand: you are using a styles.js file just to "automagically" require all your styles in a single entry. Is that right?

Using 'js' as a style extension will probably broke your build completely, since the empty output js is not really empty, so the plugin just delete any js file from any js entry it matches.

What I think you can do is, use something like "styles.css.js" and use "css.js" as your style extension. I am busy right now, so I have not tested it, but try this:

Config

entry: {
  app: './entries/application.js',
  styles: './entries/styles.css.js'
},
plugins: [
  new FixStyleOnlyEntriesPlugin({ extensions:['css.js'] }),
]

styles.css.js

require.context('../css', false, /\.css$/);
require.context('../components', true, /\.css$/);
require.context('../pages', true, /\.css$/);

And please, let me know if it works.

@CyberAP
Copy link
Contributor Author

CyberAP commented Dec 12, 2018

Worked like a charm. Thanks a lot!

@CyberAP CyberAP closed this as completed Dec 12, 2018
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

2 participants
  NODES
COMMUNITY 2
Project 5
USERS 1