diff --git a/defaults.js b/defaults.js index a3cd1b5..75b2354 100644 --- a/defaults.js +++ b/defaults.js @@ -3,5 +3,6 @@ module.exports = { id: 'com.vue.example.app', appName: 'VueExampleAppName', platforms: ['android', 'ios', 'browser', 'osx'], - routerMode: 'hash' + routerMode: 'hash', + gitIgnoreContent: '*\n*/\n!.gitignore' } diff --git a/generator.js b/generator.js index 8573af1..63b7c09 100644 --- a/generator.js +++ b/generator.js @@ -103,7 +103,7 @@ module.exports = (api, options) => { const wwwIgnorePath = api.resolve(`${cordovaPath}/www/.gitignore`) api.exitLog(`Creating file: ${wwwIgnorePath}`) - fs.writeFileSync(wwwIgnorePath, '*\n*/\n!.gitignore') + fs.writeFileSync(wwwIgnorePath, defaults.gitIgnoreContent) // platforms const srcCordovaPath = api.resolve(cordovaPath) diff --git a/index.js b/index.js index 867ebf8..ce6b43c 100644 --- a/index.js +++ b/index.js @@ -193,12 +193,21 @@ module.exports = (api, options) => { args.dest = cordovaPath + '/www' // build await api.service.run('build', args) + + // add www/.gitignore again (because build will delete it) + addGitIgnoreToWWW() + // cordova clean await cordovaClean() // cordova build --release (if you want a build debug build, use cordovaBuild(platform, false) await cordovaBuild(platform) } + const addGitIgnoreToWWW = () => { + const wwwIgnorePath = api.resolve(`${cordovaPath}/www/.gitignore`) + fs.writeFileSync(wwwIgnorePath, defaults.gitIgnoreContent) + } + const runPrepare = async (args) => { // add cordova.js, define process.env.CORDOVA_PLATFORM chainWebPack(null) @@ -207,6 +216,9 @@ module.exports = (api, options) => { // build await api.service.run('build', args) + // add www/.gitignore again (because build will delete it) + addGitIgnoreToWWW() + // cordova prepare await cordovaPrepare() }