当我为开发或生产构建应用程序时,我想修改index.html文件。
我需要注入一个<script>
如果是生产,另一个<script>
如果是开发
实际上我用这个--->
https://github.com/driftyco/ionic-app-scripts
还有这个JS
const rollupConfig = require('@ionic/app-scripts/config/rollup.config');
const replace = require('rollup-plugin-replace');
const isProd = (process.env.IONIC_ENV === 'prod');
console.log('✓ ENVIRONMENT IS PRODUCTION: ', isProd);
const rollupConfigReplaceEnviroment = replace({
exclude: 'node_modules/**',
// use the /environments/environment.dev as the default import(!), no stub needed.
// note we only replace the "last" part of the import statement so relative paths are maintained
'/environments/environment.dev' : ( isProd ? '/environments/environment.prod' : '/environments/environment.dev'),
});
rollupConfig.plugins = rollupConfig.plugins || [];
rollupConfig.plugins.splice(0, 0, rollupConfigReplaceEnviroment);
module.exports = rollupConfig;
谢谢
最佳答案
您需要以不同的方式调用build才能使用该汇总配置:"build": "ionic-app-scripts build --rollup ./config/rollup.config.js",
关于typescript - ionic 2修改Index.html,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44175876/