-
Notifications
You must be signed in to change notification settings - Fork 1
Classes added from composes
are not minified in html
#1
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
Comments
Hey @davemcorwin, I can't seem to reproduce this. Let me know if you get an example working. :) |
@odensc I pushed up an example showing the issue here Please take a look if you can, perhaps I'm doing something wrong. Thanks! the gist is:
Perhaps there is a clue in the webpack output?
|
and the webpack config
|
it looks like the classes in the output are NOT modified as well. I don't the issue is really in this repo, i don't think the classes are even being seen. |
closing, this is a css-loader issue. webpack-contrib/css-loader#524 |
In the meantime, I made something hacky that works. Try this: const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const { Minifier } = require('css-loader-minify-class')
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: require.resolve('style-loader'),
use: {
loader: require.resolve('css-loader'),
options: {
minimize: true,
modules: true,
camelCase: true,
localIdentName: '[minify][local]',
},
},
})
}
]
},
plugins: [
new ExtractTextPlugin('styles.css'),
]
}
const minifier = new Minifier();
Object.defineProperty(module.exports, 'customInterpolateName', {
enumerable: false,
value: function(url) {
if (url.includes('[minify]')) {
const localName = url.replace('[minify]', '');
return minifier.getLocalIdent(this, null, localName);
}
}
}) |
Dude, brilliant.
On July 23, 2017 at 2:55:34 PM, Oden ([email protected]) wrote:
const minifier = new Minifier();
Object.defineProperty(module.exports, 'customInterpolateName', {
enumerable: false,
value: function(url) {
if (url.includes('[minify]')) {
const localName = url.replace('[minify]', '');
return minifier.getLocalIdent(this, null, localName);
}
}
})
|
:D Not the most ideal solution but it works until css-loader is fixed. I'll see if they'll accept a PR to fix it - if not, I'll add something like this into the module. |
Hey @davemcorwin, according to webpack-contrib/css-loader#583 (comment) - adding |
looks good, thanks for looking into this! |
I'll try to put together a reproducible example to add to this, but in the meantime it appears that if I have:
// bar.css
.class2 {
composes: class1 from './foo.css'
}
// index.html
which without minification would result in
with minification results in
where
a
is the minified version of.class2
. The classes in the css itself are minified properly, its just the classes in the markup that are affected. I am also using postcss, so in creating an example to add i'll make sure that is not the cause of the issue!Thanks!
The text was updated successfully, but these errors were encountered: