1- /* The webpack dev server's port to use
1+ /* The following are environment variables imported from .env, and their
2+ * defaults. Here, we destructure them from process.env and then export them as
3+ * constants.
24 */
3- export const DEV_SERVER_PORT = process . env . DEV_SERVER_PORT || 3001 ;
5+ export const {
6+ NODE_ENV , DEV_SERVER_PORT , DEV_SERVER_HOSTNAME , WEBPACK_OUTPUT_PATH ,
7+ ASSET_HOST , ASSET_PATH , ANALYZE
8+ } = process . env ;
49
5- /* The hostname to use for the webpack dev server
6- */
7- export const DEV_SERVER_HOSTNAME = process . env . DEV_SERVER_HOSTNAME || 'localhost' ;
8-
9- /* The URL of the dev server including the hostname and port
10- */
10+ // The URL of the dev server including the hostname and port
1111export const DEV_SERVER_HOST_URL = `http://${ DEV_SERVER_HOSTNAME } :${ DEV_SERVER_PORT } ` ;
1212
13- /* The output path of the completed webpack build
14- */
15- export const OUTPUT_PATH = process . env . OUTPUT_PATH || 'dist/' ;
16-
17- /* The asset host to use inside the built webpack files. In product, set the
18- * ASSET_HOST environment variable.
19- */
20- export const ASSET_HOST = (
21- process . env . NODE_ENV === 'production'
22- ? process . env . ASSET_HOST || '/dist/'
23- : process . env . ASSET_HOST || ( DEV_SERVER_HOST_URL + '/' + OUTPUT_PATH )
24- ) ;
13+ // The asset host to use for webpack files. In development, we will always use
14+ // the dev server's URL.
15+ export const ASSET_URL = (
16+ NODE_ENV === 'development'
17+ ? `${ DEV_SERVER_HOST_URL } ${ WEBPACK_OUTPUT_PATH } `
18+ : ASSET_HOST
19+ ) ;
2520
2621/* The identifier to use for css-modules.
2722 */
@@ -43,6 +38,7 @@ export const RESOLVE_PATHS = {
4338 constants : 'common/js/constants' ,
4439 css : 'common/css' ,
4540 fonts : 'common/fonts' ,
41+ gql : 'common/gql' ,
4642 images : 'common/images' ,
4743 layouts : 'common/layouts' ,
4844 lib : 'common/js/lib' ,
@@ -52,3 +48,28 @@ export const RESOLVE_PATHS = {
5248 selectors : 'common/js/selectors' ,
5349 store : 'common/js/store'
5450} ;
51+
52+ // Loader options to use for .scss files. This is here to avoid repetition
53+ // between different webpack config files.
54+ export const SCSS_LOADERS = {
55+ fallback : 'style-loader' ,
56+ use : [
57+ {
58+ loader : 'css-loader' ,
59+ options : {
60+ modules : true ,
61+ minimize : false ,
62+ importLoaders : 1 ,
63+ localIdentName : CSS_MODULES_IDENTIFIER
64+ }
65+ } ,
66+ { loader : 'postcss-loader' } ,
67+ { loader : 'sass-loader' } ,
68+ {
69+ loader : 'sass-resources-loader' ,
70+ options : {
71+ resources : './common/css/utils/*.scss'
72+ }
73+ }
74+ ]
75+ } ;
0 commit comments