This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(livesync): enable webpack with watch (#433)
* feat(livesync): enable webpack with watch Plug into NativeScript CLI's LiveSync pipeline in order to enable incremental webpacking with watch. Includes: * Instruct CLI to watch `App_Resources` directory only * Launch `webpack` with `--watch` on before-watch hook * Do not launch multiple `webpack` processes * refactor(livesync): extract app as constant * chore(livesync): make code synchronous * fix: do not rebuild every time * fix: emit absolute paths
- Loading branch information
1 parent
cfc0a57
commit 847a56f
Showing
10 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { runWebpackCompiler } = require("./compiler"); | ||
|
||
module.exports = function ($mobileHelper, $projectData, hookArgs) { | ||
if (hookArgs.config) { | ||
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions; | ||
if (appFilesUpdaterOptions.bundle) { | ||
const platforms = hookArgs.config.platforms; | ||
return Promise.all(platforms.map(platform => { | ||
const env = hookArgs.config.env || {}; | ||
const config = { | ||
env, | ||
platform, | ||
bundle: appFilesUpdaterOptions.bundle, | ||
watch: true | ||
}; | ||
|
||
return runWebpackCompiler(config, $mobileHelper, $projectData, hookArgs); | ||
})); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { AppDirectoryLocation } = require("./constants"); | ||
|
||
module.exports = function (hookArgs) { | ||
if (hookArgs.liveSyncData && hookArgs.liveSyncData.bundle) { | ||
return (args, originalMethod) => { | ||
return originalMethod().then(originalPatterns => { | ||
const appDirectoryLocationIndex = originalPatterns.indexOf(AppDirectoryLocation); | ||
if (appDirectoryLocationIndex !== -1) { | ||
originalPatterns.splice(appDirectoryLocationIndex, 1); | ||
} | ||
|
||
return originalPatterns; | ||
}); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
AppDirectoryLocation: "app" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters