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

Useable style loader does not work after build #343

Closed
kirill-konshin opened this issue Jul 11, 2017 · 6 comments
Closed

Useable style loader does not work after build #343

kirill-konshin opened this issue Jul 11, 2017 · 6 comments

Comments

@kirill-konshin
Copy link

This issue is a:

  • Bug report

NWB version is 0.18.6.

If NWB is used with useable styles loader it works well in dev mode but throws an error if build is served.

Setup:

nwb.config.js

module.exports = {
    type: 'react-app',
    webpack: {
        rules: {
            'sass-style': {
                loader: 'style-loader/useable'
            }
        }
    }
};

src/index.js

import React from "react";
import {render} from "react-dom";
import style from "./index.scss";

style.use(); // <----- this line will produce error in build version

const App = () => (<div>Foo</div>);
render(<App/>, document.getElementById('app'));

src/index.scss

body {
    color: red;
}

Steps to reproduce:

  1. Build
  2. Serve as static
  3. Open browser
  4. Observe error: index.js:6 Uncaught TypeError: t.n(...).a.use is not a function
@insin
Copy link
Owner

insin commented Jul 11, 2017

nwb uses ExtractTextPlugin to extract CSS in builds.

According to these issues you can't extract usable styles:

If you need to disable use of ExtractTextPlugin in builds, I could add setting webpack.extractText config to false as a way of disabling it.

@kirill-konshin
Copy link
Author

kirill-konshin commented Jul 11, 2017

you can't extract usable styles

Totally makes sense

Previously it used to work w/o extra config... but if you can add a way of disabling this, please go ahead.

I think that webpack.extractText: false|null should be just enough: a strict check that if it's defined and is falsy then disable the plugin, but undefined will just use default config.

@insin
Copy link
Owner

insin commented Jul 11, 2017

If it used to work and the stylesheet was in a split chunk you could try webpack.extractText = {allChunks: false} config - the default was changed to true a while back to avoid pulling the style-loader runtime into every build.

@kirill-konshin
Copy link
Author

Yep, that's the case, it is working with allChunks: false. That's a very bad change, it's backward incompatible... I understand the rationale, but still...

In any case, I hope to see a setting to completely disable the extract text plugin because for useable styles case it is useless.

@kirill-konshin
Copy link
Author

What will be the ETA of change?

@insin insin closed this as completed in 6a42b94 Jul 12, 2017
@kirill-konshin
Copy link
Author

Fix confirmed.

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