Closed tan-90 closed 5 years ago
try atsm sources -p */.sass -o types -w
It behaves the same way, I can generate the typings if I don't set the -w flag. If I do, it does nothing.
Really, its doesn't working.
I also tried to run it with admin privileges, so that's not the issue. If you have any ideas on what the problem could be or any tests I could do, I'm open to help.
No, i have no idea... Its a bug. First i used it, but then delete... I use webpack + typed-css-modules-loader for sass typings generation.
That seems like a better approach. Can I use typed-css-modules-loader with scss?
May be. Try it.
{
test: /\.scss$/,
use: [
...,
{
loader: 'typed-css-modules-loader',
options: {
noEmit: true,
outDir: 'types',
searchDir: 'sources'
}
}, {
loader: 'sass-loader'
}
],
}
typed-css-modules-loader doesn't work with the version of css-loader I'm using, but I managed to find a replacement that does work. The only problem is the TypeScript compiler sometimes runs before the typings are generated and that breaks things. This seems like the best possible way though, unless I write a new loader.
Thank you very much (also I was mistaking you for the owner of the repo, so sorry about that). Web is a frustrating mess.
In my case TypeScript compiler always runs before typings are generated. I found a two reasons: 1 - Double compiling that use two webpack configs (but x2 long compilation time, i drop this idea) 2 - Delete types before compiling typescripts, and then generate it from loader (in that case we can see a incorrect style using in IDE - WebStorm, but it compiling without errors)
Hi, thanks for your interest in this project. The timing issue is one of the reason I wrote this tool. I also wrote a webpack plugin to pair with it to solve the timing issue (https://www.npmjs.com/package/webpack-synchronizable-shell-plugin).
This plugin allows you to run a script before the build starts, it also blocks the build until the script finishes, so you will run atsm
to generate the d.ts files in the prebuild step and when typescript runs, the d.ts files will be there.
I will take a look at the -w issue and report back once I found the fix.
Okay. The issue was that chokidar only accepts forward slashes in the glob pattern while node's path.join
API returns path in backslashes on Windows.
I have fixed the issue by replacing backslashes with forward slashes before passing glob path to chokidar. Version 1.1.6 has been published with this fix.
Works perfectly, thank you very much!
For anyone stumbling upon this, here's all you need:
plugins: [
new WebpackSynchronizableShellPlugin({
onBuildStart: {
scripts: [
'echo "Generating scss typings."',
'atsm -p src/**/*.scss'
],
blocking: true
}
}),
copyPlugin
]
I've been looking for this for a long time now and it works exactly as I wanted if I run it normally, but I don't seem to be able to get the watch to work.
Here's what I'm trying.
atsm -p src/**/*.scss -w
And it doesn't change the output files on saving the input.