fqborges / webpack-fix-style-only-entries

Webpack plugin to solve the problem of having a style only entry (css/sass/less) generating an extra js file.
ISC License
268 stars 20 forks source link

Not working for dynamically imported css? #19

Open arichter83 opened 5 years ago

arichter83 commented 5 years ago

I tried this package, but it did not work for me. I created something to reproduce:

git clone -b using-MiniCssExtractPlugin https://github.com/arichter83/meteor-react-typescript-nightwatch.git
meteor npm install
meteor 

In Info.tsx there is a dynamic import:

import(/* webpackChunkName: "info" */ '../../client/info.css')

This will generate a info.js and a info.css:

I20190710-18:56:58.603(2)?     info.21e44ad1ca43ac862441.js  392 bytes    info  [emitted]  info
I20190710-18:56:58.603(2)?                         info.css   30 bytes    info  [emitted]  info

And the info.js will still be loaded in the client, even though I think it is obsolete:

(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["info"],{

/***/ "./client/info.css":
/*!*************************!*\
  !*** ./client/info.css ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./client/info.css?");

/***/ })

}]);

And in my webpack.config.js I use the plugin:

new FixStyleOnlyEntriesPlugin(),

Where is my mistake? Thank you for your help.

PS: I also added a StackOverflow question https://stackoverflow.com/questions/56937912/webpack-dynamic-import-scss-generates-tiny-js-files

yaroslavvertukhov commented 4 years ago

I have the same problem

yaroslavvertukhov commented 4 years ago

@arichter83 Did you find a solution?