@@ -9,6 +9,7 @@ import babelify from 'babelify';
99import modulesify from 'css-modulesify' ;
1010import source from 'vinyl-source-stream' ;
1111import buffer from 'vinyl-buffer' ;
12+ import { argv } from 'yargs' ;
1213import { dirs } from './config' ;
1314import { customSass } from './compilers' ;
1415
@@ -21,7 +22,7 @@ gulp.task('build:test', () => gulp.src([
2122 . pipe ( sourcemaps . write ( ) )
2223 . pipe ( gulp . dest ( dirs . buildTest ) ) ) ;
2324
24- gulp . task ( 'build:client' , [ 'copy:client' ] , ( ) => {
25+ gulp . task ( 'build:client' , [ 'copy:client' , 'copy:config:server' ] , ( ) => {
2526 vueify . compiler . applyConfig ( {
2627 sass : {
2728 includePaths : [
@@ -58,6 +59,18 @@ gulp.task('build:client', ['copy:client'], () => {
5859 } ,
5960 } ) ;
6061
62+ if ( argv . production ) {
63+ b . transform ( aliasify , {
64+ replacements : {
65+ '(.+)server/config.json$' : path . resolve (
66+ dirs . buildServer ,
67+ 'config.json' ,
68+ ) ,
69+ } ,
70+ verbose : true ,
71+ } ) ;
72+ }
73+
6174 return b . bundle ( )
6275 . pipe ( source ( 'bundle.js' ) )
6376 . pipe ( buffer ( ) )
@@ -74,7 +87,7 @@ gulp.task('build:common', () => {
7487 . pipe ( gulp . dest ( dirs . buildCommon ) ) ;
7588} ) ;
7689
77- gulp . task ( 'build:server' , [ 'copy:server' ] , ( ) => {
90+ gulp . task ( 'build:server' , [ 'copy:server' , 'copy:config:server' ] , ( ) => {
7891 return gulp . src ( path . resolve ( dirs . srcServer , '**/*.js' ) )
7992 . pipe ( sourcemaps . init ( ) )
8093 . pipe ( babel ( ) )
0 commit comments