Skip to content

fix loading css files from node_modules; use new exportOnlyLocals #54

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

Merged
merged 1 commit into from
Jan 17, 2019

Conversation

tomconroy
Copy link
Contributor

No description provided.

@tomconroy tomconroy requested review from vabruzzo and carlyle January 17, 2019 18:36
@@ -34,7 +63,9 @@ module.exports = merge.smart({
path: path.resolve('build'),
},
// put all node_modules into externals (require() them as usual w/o webpack)
externals: [nodeExternals()],
externals: [nodeExternals({
whitelist: /\.css$/,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this, the node server is trying to require() css files

@@ -8,10 +8,10 @@ module.exports = Object.assign({}, defaults, {
entry: ['webpack/hot/poll?1000'].concat(defaults.entry),
watch: true,
externals: [nodeExternals({
whitelist: ['webpack/hot/poll?1000'],
whitelist: ['webpack/hot/poll?1000', /\.css$/],
Copy link
Contributor Author

@tomconroy tomconroy Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge.smart doesn't seem to handle this nodeExternals, i guess since this thing returns a function. so this is repeated

const req = loaderUtils.stringifyRequest(this, `!!${remainingRequest}`);
return `var content = require(${req});

if (content.locals) module.exports = content.locals;`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed since this is natively supported in css-loader now! 🎉

],
},
{
test: /\.css$/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these two css tests be merged to one if we pass an array of paths to include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we need different config for the node_modules paths. the src paths use our old postcss pipeline as well as modules, so classnames in external packages were transformed to something like .___node_modules____foo-bar-baz

@tomconroy tomconroy merged commit d29ca7e into typescript-support Jan 17, 2019
@tomconroy tomconroy deleted the css-external-modules branch January 17, 2019 21:33
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

Successfully merging this pull request may close these issues.

3 participants