Skip to content

Instantly share code, notes, and snippets.

@andrewMuntyan
Created April 14, 2018 14:05
Show Gist options
  • Save andrewMuntyan/4d68d3dd3706f74d5eb0f587105aa2c5 to your computer and use it in GitHub Desktop.
Save andrewMuntyan/4d68d3dd3706f74d5eb0f587105aa2c5 to your computer and use it in GitHub Desktop.
const result = {
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
babelrc: true,
plugins: ['react-hot-loader/babel']
}
},
{
loader: 'ts-loader',
options: {
configFile: path.resolve(configDir, 'tsconfig.json')
}
}
]
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 10000
}
},
]
},
output: {
filename: '[name].bundle.js',
path: distDir
},
plugins: [...],
resolve: {
modules: [srcDir, nodeModulesDir],
extensions: ['.tsx', '.ts', '.js', '.jsx']
},
};
module.exports = result;
.large-image {
&--bg {
composes: large-image;
background: url('./large-image.jpg');
background-size: 100px 100px;
}
}
declare module "*.jpg" {
const value: string;
export default value;
}
import * as React from 'react';
import * as styles from './cssModules.css';
import image from './large-image.jpg';
console.log('----------');
console.log('image');
console.log(image);
console.log('----------');
export default class CssModules extends React.Component<{}, {}> {
render() {
return (
<section className={styles.root}>
<div className={styles.largeImageBg} />
<img className={styles.largeImageImage} src={image} alt="" />
</section>
);
}
}
{
"compilerOptions": {
"outDir": "../dist/",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"sourceMap": true,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"allowJs": true,
"strictNullChecks": true,
"typeRoots": [
"../typings",
"../node_modules/@types"
]
},
"include": [
"../src/**/*",
"../typings/**/*"
],
"exclude": [
"../node_modules",
"**/*.spec.ts"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment