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
need to support ES6 module #210
Comments
Looking at my project, css-loader is exporting all of the class names both under If I have :local(.subtitle) {
font-size: 0.75em;
}
:local(.title) {
font-feature-settings: 'onum';
} its exporting them such that the exported module looks like module.exports = {
subtitle: '<hash>',
title: '<hash>',
default: {
subtitle: '<hash>',
title: '<hash>',
},
} I will note that if you're wanting to import a specific class name, you'll need to use the brace style of import: I've been doing |
Hi hawkrives, I'm not sure I get what you mean, In my example, I write .bi-tab {xx}, then import {xx} from './x.css' or import xx from './x.css', I get this compiled javascript showing no default. Pls correct me:) function(module, exports, webpack_require) {
|
Ok, hang on a second. First things first: are you using the Anyway, I just tested this set of files, and they worked. When I open this Does this config work for you? I built it with
{
"main": "index.js",
"devDependencies": {
"webpack": "^2.0.7-beta"
}
}
.className {
background-color: red;
}
:local(.className) {
background-color: red;
}
import {className} from './styles.css'
let div = document.createElement('div')
div.className = className
div.textContent = 'Words!'
document.body.appendChild(div)
module.exports = {
entry: ['./index.js'],
output: {
path: './',
filename: 'bundle.js',
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader?modules' }, // important! you have to either have `?modules` or use the `:local` thingy in your css files.
],
},
}
<body></body>
<script src='./bundle.js'></script> My exports = module.exports = __webpack_require__(1)();
// imports
// module
exports.push([module.id, "._163b4mm1fitxanXK3GM0_t {\n background-color: red;\n}\n", ""]);
// exports
exports.locals = {
"className": "_163b4mm1fitxanXK3GM0_t"
}; |
@hawkrives thank you for your guide! I totally get what you mean, however it's not in my case, I'm sorry I didn't describe it correctly. I'm trying Angular2 currently, if I want to develop a component called bi-tabs, // bi-tabs.css file, } // in bi-tabs.ts file, I think the bundle may be like: export.default = {whole content string in css file} Thanks! |
@hawkrives, I think show you the code is more clear:
Build:
|
Will be fixed by #402 |
Is this the kind of problem I should expect to see in the current state?
|
I'm using webpack 2.0 beta, if I want to " import xx from 'x.css' ", then pass xx string to the style config(like styles: xx), running will go wrong cause the build will be: "styles: xx.default", however cssloader will be : "module.exports=xx", not "module['default']=xx".
The text was updated successfully, but these errors were encountered: