| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 1 | const CompressionPlugin = require('compression-webpack-plugin'); | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 2 |  | 
| Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame] | 3 | module.exports = { | 
| Yoshie Muranaka | d388a28 | 2020-07-08 16:15:46 -0700 | [diff] [blame] | 4 |   css: { | 
 | 5 |     loaderOptions: { | 
 | 6 |       sass: { | 
 | 7 |         prependData: () => { | 
 | 8 |           const envName = process.env.VUE_APP_ENV_NAME; | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 9 |           const hasCustomStyles = | 
 | 10 |             process.env.CUSTOM_STYLES === 'true' ? true : false; | 
 | 11 |           if (hasCustomStyles && envName !== undefined) { | 
| Yoshie Muranaka | d388a28 | 2020-07-08 16:15:46 -0700 | [diff] [blame] | 12 |             // If there is an env name defined, import Sass | 
 | 13 |             // overrides. | 
 | 14 |             // It is important that these imports stay in this | 
 | 15 |             // order to make sure enviroment overrides | 
 | 16 |             // take precedence over the default BMC styles | 
 | 17 |             return ` | 
 | 18 |               @import "@/assets/styles/bmc/helpers"; | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 19 |               @import "@/env/assets/styles/_${envName}"; | 
| Yoshie Muranaka | d388a28 | 2020-07-08 16:15:46 -0700 | [diff] [blame] | 20 |               @import "@/assets/styles/bootstrap/_helpers"; | 
 | 21 |             `; | 
 | 22 |           } else { | 
 | 23 |             // Include helper imports so single file components | 
 | 24 |             // do not need to include helper imports | 
 | 25 |  | 
 | 26 |             // BMC Helpers must be imported before Bootstrap helpers to | 
 | 27 |             // take advantage of Bootstrap's use of the Sass !default | 
 | 28 |             // statement. Moving this helper after results in Bootstrap | 
 | 29 |             // variables taking precedence over BMC's | 
 | 30 |             return ` | 
 | 31 |               @import "@/assets/styles/bmc/helpers"; | 
 | 32 |               @import "@/assets/styles/bootstrap/_helpers"; | 
 | 33 |             `; | 
 | 34 |           } | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 35 |         }, | 
 | 36 |       }, | 
 | 37 |     }, | 
| Yoshie Muranaka | d388a28 | 2020-07-08 16:15:46 -0700 | [diff] [blame] | 38 |   }, | 
| Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame] | 39 |   devServer: { | 
| Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 40 |     https: true, | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 41 |     proxy: { | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 42 |       '/': { | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 43 |         target: process.env.BASE_URL, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 44 |         onProxyRes: (proxyRes) => { | 
| Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 45 |           // This header is ignored in the browser so removing | 
| Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 46 |           // it so we don't see warnings in the browser console | 
 | 47 |           delete proxyRes.headers['strict-transport-security']; | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 48 |         }, | 
 | 49 |       }, | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 50 |     }, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 51 |     port: 8000, | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 52 |   }, | 
 | 53 |   productionSourceMap: false, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 54 |   configureWebpack: (config) => { | 
| Yoshie Muranaka | 9e36f52 | 2020-02-05 07:42:34 -0800 | [diff] [blame] | 55 |     const envName = process.env.VUE_APP_ENV_NAME; | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 56 |     const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false; | 
 | 57 |     const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false; | 
| Yoshie Muranaka | 0214fed | 2020-09-03 13:25:50 -0700 | [diff] [blame] | 58 |     const hasCustomAppNav = | 
 | 59 |       process.env.CUSTOM_APP_NAV === 'true' ? true : false; | 
| Yoshie Muranaka | 9e36f52 | 2020-02-05 07:42:34 -0800 | [diff] [blame] | 60 |  | 
| Yoshie Muranaka | 9e36f52 | 2020-02-05 07:42:34 -0800 | [diff] [blame] | 61 |     if (envName !== undefined) { | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 62 |       if (hasCustomStore) { | 
| Yoshie Muranaka | 816d947 | 2020-09-03 11:19:28 -0700 | [diff] [blame] | 63 |         // If env has custom store, resolve all store modules. Currently found | 
 | 64 |         // in src/router/index.js src/store/api.js and src/main.js | 
 | 65 |         config.resolve.alias['./store$'] = `@/env/store/${envName}.js`; | 
 | 66 |         config.resolve.alias['../store$'] = `@/env/store/${envName}.js`; | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 67 |       } | 
 | 68 |       if (hasCustomRouter) { | 
| Yoshie Muranaka | 816d947 | 2020-09-03 11:19:28 -0700 | [diff] [blame] | 69 |         // If env has custom router, resolve routes in src/router/index.js | 
 | 70 |         config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`; | 
| Yoshie Muranaka | 044b1bb | 2020-08-12 14:12:44 -0700 | [diff] [blame] | 71 |       } | 
| Yoshie Muranaka | 0214fed | 2020-09-03 13:25:50 -0700 | [diff] [blame] | 72 |       if (hasCustomAppNav) { | 
 | 73 |         // If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue | 
 | 74 |         config.resolve.alias[ | 
 | 75 |           './AppNavigationMixin$' | 
 | 76 |         ] = `@/env/components/AppNavigation/${envName}.js`; | 
 | 77 |       } | 
| Yoshie Muranaka | 9e36f52 | 2020-02-05 07:42:34 -0800 | [diff] [blame] | 78 |     } | 
| Yoshie Muranaka | 816d947 | 2020-09-03 11:19:28 -0700 | [diff] [blame] | 79 |  | 
 | 80 |     if (process.env.NODE_ENV === 'production') { | 
 | 81 |       config.plugins.push( | 
 | 82 |         new CompressionPlugin({ | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 83 |           deleteOriginalAssets: true, | 
| Yoshie Muranaka | 816d947 | 2020-09-03 11:19:28 -0700 | [diff] [blame] | 84 |         }) | 
 | 85 |       ); | 
 | 86 |     } | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 87 |   }, | 
| Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 88 |   pluginOptions: { | 
 | 89 |     i18n: { | 
 | 90 |       localeDir: 'locales', | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 91 |       enableInSFC: true, | 
 | 92 |     }, | 
 | 93 |   }, | 
| Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame] | 94 | }; |