@@ -48,6 +48,19 @@ function getPort(port) { |
48 | 48 | return port || process.env['NULLSTACK_SERVER_PORT'] || process.env['PORT'] || 3000 |
49 | 49 | } |
50 | 50 |
|
| 51 | +function clearOutput(outputPath) { |
| 52 | + if (!existsSync(outputPath)) return |
| 53 | + readdir(outputPath, (err, files) => { |
| 54 | + if (err) throw err; |
| 55 | + for (const file of files) { |
| 56 | + if (file === '.cache') continue; |
| 57 | + unlink(path.join(outputPath, file), err => { |
| 58 | + if (err) throw err; |
| 59 | + }); |
| 60 | + } |
| 61 | + }); |
| 62 | +} |
| 63 | + |
51 | 64 | async function start({ input, port, env, mode = 'spa', cold, disk }) { |
52 | 65 | const environment = 'development' |
53 | 66 | console.log(` 🚀️ Starting your application in ${environment} mode...`); |
@@ -123,16 +136,7 @@ async function start({ input, port, env, mode = 'spa', cold, disk }) { |
123 | 136 | port: process.env['NULLSTACK_SERVER_PORT'] |
124 | 137 | }; |
125 | 138 | const compiler = getCompiler({ environment, input, disk }); |
126 | | - const outputPath = compiler.compilers[0].outputPath; |
127 | | - readdir(outputPath, (err, files) => { |
128 | | - if (err) throw err; |
129 | | - for (const file of files) { |
130 | | - if (file === '.cache') continue; |
131 | | - unlink(path.join(outputPath, file), err => { |
132 | | - if (err) throw err; |
133 | | - }); |
134 | | - } |
135 | | - }); |
| 139 | + clearOutput(compiler.compilers[0].outputPath) |
136 | 140 | const server = new WebpackDevServer(devServerOptions, compiler); |
137 | 141 | const portChecker = require('express')().listen(process.env['NULLSTACK_SERVER_PORT'], () => { |
138 | 142 | portChecker.close() |
|