// project.config.js
const
config
=
{
env
:
process
.
env
.
NODE_ENV
||
'development'
,
// ----------------------------------
// Project Structure
// ----------------------------------
path_base
:
path
.
resolve
(
__dirname
,
'..'
),
dir_client
:
'src'
,
dir_dist
:
'dist'
,
dir_public
:
'public'
,
dir_server
:
'server'
,
dir_test
:
'tests'
,
// ----------------------------------
// Server Configuration
// ----------------------------------
server_host
:
ip
.
address
(),
// use string 'localhost' to prevent exposure on local network
server_port
:
process
.
env
.
PORT
||
3000
,
// ----------------------------------
// Compiler Configuration
// ----------------------------------
compiler_devtool
:
'source-map'
,
compiler_hash_type
:
'hash'
,
compiler_fail_on_warning
:
false
,
compiler_quiet
:
false
,
compiler_public_path
:
'/'
,
compiler_stats
:
{
chunks
:
false
,
chunkModules
:
false
,
colors
:
true
}
};
// 在此通过读取环境变量读取environments中对应的配置项,对前面的配置项进行覆盖
const
environments
=
require
(
'./environments.config'
)
const
overrides
=
environments
[
config
.
env
]
if
(
overrides
)
{
debug
(
'Found overrides, applying to default configuration.'
)
Object
.
assign
(
config
,
overrides
(
config
))
}
else
{
debug
(
'No environment overrides found, defaults will be used.'
)
}
module
.
exports
=
config
const
webpack
=
require
(
'webpack'
)
const
project
=
require
(
'./project.config'
)
const
debug
=
require
(
'debug'
)(
'app:config:webpack'
)
const
UglifyJsParallelPlugin
=
require
(
'webpack-uglify-parallel'
)
const
__DEV__
=
project
.
globals
.
__DEV__
const
__PROD__
=
project
.
globals
.
__PROD__
const
webpackConfig
=
{
name
:
'client'
,
target
:
'web'
,
devtool
:
project
.
compiler_devtool
,
resolve
:
{
modules
:
[
project