Repository navigation
Closed
Description
css modules inside node_modules are working but css modules on my source are not added but loaded.
css is missed
require('babel-polyfill');
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const FlowtypePlugin = require('flowtype-loader/plugin');
const assetsPath = path.resolve(__dirname, '../static/dist');
const host = (process.env.HOST || 'localhost');
const port = (+process.env.PORT + 1) || 4001;
const rootPath = path.join(__dirname, './..');
const nodeModulesPath = path.join(rootPath, 'node_modules');
// Isomorfic Tools
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
const WebpackIsomorphicToolsPlugin =
require('webpack-isomorphic-tools/plugin');
const webpackIsomorphicToolsPlugin =
new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));
// Babel config update to for client
const babelrc = fs.readFileSync('./.babelrc');
let babelrcObject = {};
try {
babelrcObject = JSON.parse(babelrc);
} catch (err) {
console.error('==> ERROR: Error parsing your .babelrc.');
console.error(err);
}
const babelrcObjectDevelopment =
babelrcObject.env && babelrcObject.env.development || {};
// merge global and dev-only plugins
let combinedPlugins = babelrcObject.plugins || [];
combinedPlugins = combinedPlugins.concat(babelrcObjectDevelopment.plugins);
const babelLoaderQuery = Object.assign(
{},
babelrcObjectDevelopment,
babelrcObject,
{ plugins: combinedPlugins }
);
delete babelLoaderQuery.env;
// Since we use .babelrc for client and server, and we don't want HMR enabled
// on the server, we have to add the babel plugin react-transform-hmr manually
// here.
// make sure react-transform is enabled
babelLoaderQuery.plugins = babelLoaderQuery.plugins || [];
let reactTransform = null;
for (let i = 0; i < babelLoaderQuery.plugins.length; ++i) {
let plugin = babelLoaderQuery.plugins[i];
if (Array.isArray(plugin) && plugin[0] === 'react-transform') {
reactTransform = plugin;
}
}
babelLoaderQuery.presets =
babelLoaderQuery.presets.map(function (item) {
if (item === 'es2015') {
return ['es2015', { modules: false }];
}
return item;
});
if (!reactTransform) {
reactTransform = ['react-transform', {transforms: []}];
babelLoaderQuery.plugins.push(reactTransform);
}
if (!reactTransform[1] || !reactTransform[1].transforms) {
reactTransform[1] = Object.assign({}, reactTransform[1], {transforms: []});
}
module.exports = {
entry: {
vendor: require('./vendorList'),
main: [
'react-hot-loader/patch',
//activate HMR for React
'webpack-hot-middleware/client?path=http://' + host + ':' + port + '/__webpack_hmr',
'./src/client.js'
//the entry point of our app
],
},
output: {
path: assetsPath,
filename: '[hash]-[id].js',
chunkFilename: '[name]-[chunkhash].js',
publicPath: 'http://' + host + ':' + port + '/assets/',
},
context: path.resolve(__dirname, '..'),
devtool: 'inline-source-map',
performance: { hints: false },
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
'react-hot-loader/webpack',
'babel-loader?' + JSON.stringify(babelLoaderQuery),
'eslint-loader',
// 'flowtype-loader',
],
}, {
test: /\.json$/,
loader: 'json-loader',
}, {
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
localIdentName: '[local]___[hash:base64:5]',
importLoaders: 2,
modules: true,
}
},
{
loader: 'postcss-loader',
options: {
plugins: (loader) => [
require('postcss-import')({
root: loader.resourcePath,
}),
require('postcss-mixins')(),
require('postcss-each')(),
require('postcss-cssnext')({
features: {
customProperties: {
variables: require('../src/theme/variables.js'),
}
}
}),
],
} ,
},
]
}, {
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
}, {
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream',
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml',
}, {
test: webpackIsomorphicToolsPlugin.regular_expression('images'),
loader: 'url-loader?limit=10',
}],
},
resolve: {
modules: [
'src',
'node_modules'
],
extensions: ['.json', '.js', '.jsx', '*'],
},
plugins: [
// new FlowtypePlugin(),
new webpack.LoaderOptionsPlugin({
options: {
context: path.resolve(__dirname, '..'),
}
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'], // Specify the common bundle's name.
}),
new webpack.HotModuleReplacementPlugin(),
//activates HMR
new webpack.NamedModulesPlugin(),
//prints more readable module names in the browser console on HMR updates
//
new webpack.IgnorePlugin(/webpack-stats\.json$/),
new webpack.DefinePlugin({
__CLIENT__: true,
__SERVER__: false,
__DEVELOPMENT__: true,
__DEVTOOLS__: true // <-------- DISABLE redux-devtools HERE
}),
webpackIsomorphicToolsPlugin.development()
],
};Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
michael-ciniawsky commentedon May 12, 2017
Maybe because you are setting
contextinLoaderOptionsPlugin(not supportd bypostcss-loader >= v2.0.0) anymore.michael-ciniawsky commentedon May 12, 2017
Which CSS is missing (from
@importonly or all CSS) ?CSS Modules from
srcornode_modules, please elaborate further on this 😛michael-ciniawsky commentedon May 12, 2017
Maybe releated to #222 (needs more info)
carlitux commentedon May 12, 2017
css modules from src are not in css bundle.
I was thinking same but how could I do same without context option?
michael-ciniawsky commentedon May 12, 2017
What it's purpose atm? I couldn't really reason about, where it actually gets used? :)
When you disable
postcss-loaderCSS Modules work ? This is odd, because they get generated bycss-loaderwhich runs afterpostcss-loader, could you post 1-2 components which import CSS ?[-]Upgrade from 1.3.3 to 2.0.5 not working as needed[/-][+][2.0.5] `css-loader: modules` not working as needed after upgrade[/+]olegstepura commentedon May 16, 2017
Hi!
I did not investigate too deep, but after upgrade from 1.x to 2.0.5 version animations are broken in a project with
react-toolbox(2.0 beta).I can confirm that it's exactly the upgrade of
postcss-loaderbreaks it. In my case it's an upgrade from1.3.3to2.0.5.But seems like there are some improvements as well, since build is now way smaller (1.1 Mb with
2.0.5vs1.5 Mb with
1.3.3) Previously I noticed lots of unprocessed postcss code in a build. Currently there are some sourcemaps inside build, but maybe it's my fault of misconfiguration.So I assume you optimized importing logic, but looks like optimizations were too hard =) It's a pity i cannot upgrade due to the mentioned issue.
alexander-akait commentedon May 16, 2017
@olegstepura can your provide minimal reproducible test repo?
michael-ciniawsky commentedon May 16, 2017
@olegstepura I need your more info on how you utilise the lib (source files,
webpack.config.js, [postcss.config.js]), normallypostcss-loaderdoesn't alter anything 'unexpected' without the plugins you use :). The biggest improvement was to not generate a sourcemap by default anymore and cleanup some old API's (webpack && PostCSS).v2.0.0uses PostCSS v6 (breaking change), so please check if your plugins are yet compatible with v6 by now, e.gcssnextisn't atm and maybe you need to manually update some plugins due to semver range inpackage.jsonolegstepura commentedon May 17, 2017
Hi, @michael-ciniawsky!
Thanks for your response. Here are my config files: gist
In
build.jsI've placed some code in which you can see that sources are still included (I would like to remove it, butsourceMap: trueinpostcss.config.jsdoes not seem to help).@evilebottnawi I will try to prepare test repo.
olegstepura commentedon May 17, 2017
Here is my test repo with react-toolbox: olegstepura/postcss-loader-test
The only change between two versions below is an edit in
package.json:And run
npm iinside test repo folder after edit.With version
1.3.3:Big screen, everything is stacked good (click to see screenshot)
Small screen, animation is smooth (click to see gif)
With version
2.0.5:Big screen, strange spacing between navbar and appbar (click to see screenshot)
Small screen (click to see gif and comments)
olegstepura commentedon May 17, 2017
Also I would love to hear any suggestion on how to remove source maps from
build.jsin my test repo.npm run buildproducessrc/main/webapp/asset/test.jsinside of that there is such content (with
postcss-loaderversion2.0.5, I inserted some newlines to make it more visually readable)this clearly states that there are source maps inside, which just make build heavier. I'm not even sure if this can somehow help debugging
alexander-akait commentedon May 17, 2017
@olegstepura without minimal repo we can't do anything, seems your use
postcssplugins based onpostcssv5, new loader working onv6, also seemssorceMap: falsedon't using in loader options.10 remaining items
alexander-akait commentedon May 18, 2017
@felixsanz Why do you duplicate it? It is create noise, just wait for someone to get free, also you can try to find the problem yourself and describe where it was found it will speed up the solution
felixsanz commentedon May 18, 2017
@evilebottnawi I'm not duplicating anything, i just moved my conversation here to avoid polluting the other issue :/
Notice that i deleted my message from the other issue. Sorry if it triggered notfiications
alexander-akait commentedon May 18, 2017
@felixsanz It would also be nice to see minimal test reproducible repo, it is difficult say that it is wrong just the configuration
alexander-akait commentedon May 18, 2017
@felixsanz just create new issue with minimal repo and what your expected and actually output. Please don't write your problems in closed issue
felixsanz commentedon May 18, 2017
@evilebottnawi I tried to create one reproducible test case but i don't even know what i'm supposed to reproduce. I don't understand whats going on, i just see that many rules just dissappeared while others are just there.
Open it then please? It's clearly not fixed
alexander-akait commentedon May 18, 2017
@felixsanz yep create new issue and try to show what is wrong (screenshots, console, example of code and etc.). Don't write here otherwise the problem may not be noticed.
michael-ciniawsky commentedon May 19, 2017
@felixsanz The only obvious thing I can see is (but likely unrelated)
{ loader: 'css-loader', - query: { + options: { modules: true, importLoaders: 1, localIdentName: '[local]-[hash:base64:5]', }, }What how does your current
postcss.config.jslook like ? Maybe try withoutimportLoadersand@import, otherwise the CSS Modules implementation is independent frompostcss-loaderit must be a bug somewhere else, which surfaces viamodulesmichael-ciniawsky commentedon May 19, 2017
Your postcss plugin versions
package.jsonaswell please.postcss-loader >= v2.0.0uses PostCSS v6 (breaking change) not all plugins support it yet, e.g if you usecssnextand it's nesting plugin, your rules are off, could be missing etc. atmfelixsanz commentedon May 19, 2017
@michael-ciniawsky It was working fine with 1.3.3. So the bug was introduced with postcss-loader 2.x, directly or indirectly.
My
.postcssrcis this:michael-ciniawsky commentedon May 19, 2017
The version of
postcss-importis>= 10.0.0?michael-ciniawsky commentedon May 19, 2017
Please also provide an input -> output example
felixsanz commentedon May 19, 2017
I'll try create a testcase, but I spent an hour before with no success. I'll try again tomorrow.
olegstepura commentedon May 19, 2017
@evilebottnawi, @michael-ciniawsky please let me know if you will answer anything to my sourcemap issue. If I should create a new separate issue, I will. If you think this is not anyhow related to
postcss-loader, please tell me as well (but please let me know where should I create such an issue). Thanks!alexander-akait commentedon May 19, 2017
@olegstepura yep, create new issue with repo and description problem, otherwise we can lose it here. Thanks!