Preact CLIは、すぐに使用できると主張してCSS Modulesいます。これが私が試したものです。2つのファイルがindex.jsありindex.module.scss、同じフォルダーにある場合、これを試しました:
index.js
import { h, Component } from 'preact';
import styles from './index.module.scss';
export default class Layout extends Component {
render() {
console.log(styles);
return (
<div className={styles.container}>
{this.props.children}
</div>
);
}
}
index.module.scss
.container {
margin: 50px auto;
max-width: 960px;
width: 100%;
}
console.logステートメントは を出力します。HTML{}のclass属性は空です。
私は何を間違っていますか?
ああ、私がやったこのものをインストールするために
preact create default my-project
yarn add -D node-sass sass-loader