Skip to content

Webpack generate unnecessary styles.js file with css entry #12

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

Closed
laozhu opened this issue Mar 5, 2018 · 5 comments
Closed

Webpack generate unnecessary styles.js file with css entry #12

laozhu opened this issue Mar 5, 2018 · 5 comments

Comments

@laozhu
Copy link

laozhu commented Mar 5, 2018

I have two entry, one for javascript bundling, one for css bundling, I use this plugin for extracting css, everything is OK except generating a unnecessary styles.af6d7e48e7.js file in my dist/js folder.

Environment

- macOS 10.13.3
- node v9.6.1
- yarn v1.3.2

Webpack entry

PATH.entry = {
  bundle: './src/index.js',
  styles: './src/styles/main.css',
};

Dist structure

ritchie at MacBook-Air in ~/D/W/w/dist
↪ tree
.
├── css
│   ├── styles.af6d7e48e7.css
│   └── styles.af6d7e48e7.css.map
├── favicon.ico
├── fonts
│   ├── lobster.58a4085516.woff2
│   └── lobster.e7f8a498bc.woff
├── img
│   └── logo.89088456bc.png
├── index.html
├── js
│   ├── bundle.32992ee976.js
│   ├── bundle.32992ee976.js.map
│   ├── dll.manifest.json
│   ├── styles.af6d7e48e7.js
│   ├── styles.af6d7e48e7.js.map
│   ├── vendor.decae7f1b9.dll.js
│   ├── vendor.decae7f1b9.dll.js.map
│   └── vendor.dll.manifest.json
├── manifest.json
└── robots.txt

I use webpack-manifest-plugin to generat assets manifest.json for backend reference, the unnecessary styles.af6d7e48e7.js is in the manifest.json. I can't use filter to remove files like styles.af6d7e48e7.js because the output filename is depending on entry name.

Example repo

laozhu/wsk

Clone the example repo and run yarn install and yarn start will get the same dist structure above.

My problem

Any idea for not generating files like styles.af6d7e48e7.js, or remove these unnecessary files from dist and manifest.json?

@sokra
Copy link
Member

sokra commented Mar 5, 2018

Your example doesn't use this plugin

@sokra sokra closed this as completed Mar 5, 2018
@laozhu
Copy link
Author

laozhu commented Mar 5, 2018

@sokra I am so sorry for that, I have not commit and push it to remote repo, now the example is using this plugin and run well with yarn start.

@ingro
Copy link

ingro commented Mar 9, 2018

Not sure if I should comment here since it's already closed but I do register the same behavior, that's not a big deal indeed, but I always get a style.js file along style.css

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Mar 9, 2018

You can't use a .css file as an entrypoint, this will generate a .js file. import the CSS file in
the JS entrypoint instead

entry.js

import style from './entry.css' 

@ingro
Copy link

ingro commented Mar 9, 2018

Well thanks Michael, that was embarrassing, I created the style entry point to better debug some issue while migrating from webpack 3 to 4 and forgot about that!

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