Last active
July 5, 2021 21:14
-
-
Save muuvmuuv/eeb98a4fd564dd30b3f32629f636af26 to your computer and use it in GitHub Desktop.
Prepare your Angular application with example data without deploying it to production
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
import { Storage } from '@capacitor/storage' | |
import * as ME from 'src/data/me.json' | |
import { STORAGE_KEY_ME_DATA } from './app/models/auth' | |
/** | |
* Prepare the application for development by pushing some example | |
* data into the cache. See {@link main.ts} for implementation details. | |
*/ | |
export async function init() { | |
await Storage.set({ | |
key: STORAGE_KEY_ME_DATA, | |
value: JSON.stringify(ME), | |
}) | |
} |
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
import { enableProdMode } from '@angular/core' | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' | |
import { AppModule } from './app/app.module' | |
import { environment } from './environments/environment' | |
if (environment.production) { | |
enableProdMode() | |
} | |
if (!environment.production) { | |
import('./angular-example-data').then((x) => x.init()) | |
} | |
platformBrowserDynamic() | |
.bootstrapModule(AppModule) | |
.then(() => console.info(`Bootstrap success 🎱`)) | |
.catch((error: unknown) => { | |
console.error('Bootstrap', error) | |
}) |
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
const webpack = require('webpack') | |
module.exports = async (config, argv) => { | |
process.env.NODE_ENV = process.env.NODE_ENV || config.mode || argv.mode || 'development' | |
// | |
// Ignore our dev example data script. | |
// | |
config.plugins.push( | |
new webpack.IgnorePlugin({ | |
resourceRegExp: /^\.\/angular-example-data$/, | |
}) | |
) | |
return config | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment