I want to use css-loader with :local() in my dev-setup.
Error: import './sidebar.css';
it compiles without problems, but then I don’t know how to access the local class names inside my .tsx file.
Error: import classNames from './sidebar.css';
Here I get: error TS2307: Cannot find module './sidebar.css'
Explanation of my installation:
.tsx files compiled into commonjs modules via gulp - typescript (ES5)- Commonjs modules compiled and passed to JS via webpack
sidebar.tsx (imported into app.tsx , if that matters)
import classNames from './sidebar.css';
sidebar.css
.sl-sidebar { background-color: yellow; }
gulpfile.js
Gulp task of compiling .tsx files .tsx modules (performed primarily before the webpack task):
gulp.task('gui-tsx', function () { return gulp.src(config.guiTsxPath + '**/*.tsx') .pipe(ts({ jsx: 'react', outDir: config.guiCompiledPath, module: 'commonjs', target: 'ES5' })) .pipe(gulp.dest(config.guiCompiledPath)); });
My gulp -webpack task:
gulp.task('gui-webpack', function () { webpack({ bail: false, debug: true, entry: './' + config.guiCompiledPath + 'app.js', output: { filename: "gui.js", path: './' + config.pubPath + 'js' }, devtool: "#inline-source-map", plugins: [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false }, output: { comments: false, semicolons: true }, sourceMap: true }) ], module: { loaders: [ { test: /\.css$/, loader: 'style-loader!css-loader?modules' }] } }, function (err, stats) { if (stats.compilation.errors.length > 0) { console.log(stats.compilation.errors[0].message); } }); });
What am I doing wrong?
Edit: I just found this: https://github.com/Microsoft/TypeScript/issues/2709 but I do not understand this. Does this mean that I have to declare my CSS as a module?