@@ -26,6 +26,17 @@ function loadEnv(name) { |
26 | 26 | dotenv.config({ path: envPath }) |
27 | 27 | } |
28 | 28 |
|
| 29 | +function clearDir() { |
| 30 | + if (existsSync(path.join(process.cwd(), '.development'))) { |
| 31 | + const tempFiles = readdirSync(path.join(process.cwd(), '.development')) |
| 32 | + for (const file of tempFiles) { |
| 33 | + if (file !== '.cache') { |
| 34 | + unlinkSync(path.join(process.cwd(), '.development', file)) |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | +} |
| 39 | + |
29 | 40 | async function start({ port, name, disk, loader, skipCache }) { |
30 | 41 | loadEnv(name) |
31 | 42 | console.info(` 🚀️ Building your application in development mode...`) |
@@ -44,12 +55,7 @@ async function start({ port, name, disk, loader, skipCache }) { |
44 | 55 | if (!process.env.NULLSTACK_WORKER_PROTOCOL) process.env.NULLSTACK_WORKER_PROTOCOL = 'http' |
45 | 56 | const settings = config[0](null, { environment, disk, loader, skipCache, name }) |
46 | 57 | const compiler = webpack(settings) |
47 | | - const tempFiles = readdirSync(path.join(process.cwd(), '.development')) |
48 | | - for (const file of tempFiles) { |
49 | | - if (file !== '.cache') { |
50 | | - unlinkSync(path.join(process.cwd(), '.development', file)) |
51 | | - } |
52 | | - } |
| 58 | + clearDir() |
53 | 59 | compiler.watch({ aggregateTimeout: 200, hot: true, ignored: /node_modules/ }, (error, stats) => { |
54 | 60 | if (error) { |
55 | 61 | console.error(error.stack || error) |
|