-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
After the latest update of style-loader
and mini-css-extract-loader
(where esModule
defaults to true
), the compilation does not work anymore.
I was able to fix that by replacing
import * as styles from './styles.module.scss';
by
import styles from './styles.module.scss';
But now the generated "styles.module.d.ts" file does not match, since TypeScript complains about the missing default
export.
I would need to change that to:
declare const styles: {
// My classes here
};
export default styles;
Would it make sense to implement a configuration option, which get's a list of all classes as parameter, and which returns a string, which is then used as content of the .d.ts file?
{
loader: 'dts-css-modules-loader',
options: {
banner: '// This file is automatically generated. Do not modify this file manually -- YOUR CHANGES WILL BE ERASED!',
customDeclaration: function (classes) {
let typings = 'declare const styles: {\n';
for (const c of classes) {
typings += `\t'${c}': string;\n`;
}
typings += '};\n\nexport default styles;\n';
return typings;
}
}
},
Activity
c0gnize commentedon Oct 12, 2020
Why not, good idea!
c0gnize commentedon Oct 12, 2020
@jens-duttke you can use this option to customize end-of-line characters (issue #18)
Add new option customTypings