Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
style(webpack_config/server): fix indent
Browse files Browse the repository at this point in the history
  • Loading branch information
Metnew committed Aug 7, 2017
1 parent 098aec2 commit 4a57bc3
Showing 1 changed file with 83 additions and 84 deletions.
167 changes: 83 additions & 84 deletions webpack_config/server/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,99 +8,98 @@ const exec = require('child_process').execSync
exec(`rm -rf ${config.distPath}/server`)

const {
BASE_API,
SENTRY_DSN,
SENTRY_PUBLIC_DSN,
NODE_ENV,
DIST_PATH,
APP_LANGUAGE,
JWT_SECRET,
PORT
BASE_API,
SENTRY_DSN,
SENTRY_PUBLIC_DSN,
NODE_ENV,
DIST_PATH,
APP_LANGUAGE,
JWT_SECRET,
PORT
} = process.env

const language = APP_LANGUAGE || 'en'

const definePluginArgs = {
'process.env.BROWSER': JSON.stringify(false),
'process.env.PORT': JSON.stringify(PORT || 4000),
'process.env.JWT_SECRET': JSON.stringify(JWT_SECRET || 'secret'),
'process.env.APP_LANGUAGE': JSON.stringify(language),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV || 'development'),
'process.env.BASE_API': JSON.stringify(BASE_API || '/api/v1'),
'process.env.SENTRY_PUBLIC_DSN': JSON.stringify(SENTRY_PUBLIC_DSN),
'process.env.SENTRY_DSN': JSON.stringify(SENTRY_DSN),
'process.env.DIST_PATH': JSON.stringify(
DIST_PATH || path.join(config.distPath, './client', language)
)
'process.env.BROWSER': JSON.stringify(false),
'process.env.PORT': JSON.stringify(PORT || 4000),
'process.env.JWT_SECRET': JSON.stringify(JWT_SECRET || 'secret'),
'process.env.APP_LANGUAGE': JSON.stringify(language),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV || 'development'),
'process.env.BASE_API': JSON.stringify(BASE_API || '/api/v1'),
'process.env.SENTRY_PUBLIC_DSN': JSON.stringify(SENTRY_PUBLIC_DSN),
'process.env.SENTRY_DSN': JSON.stringify(SENTRY_DSN),
'process.env.DIST_PATH': JSON.stringify(
DIST_PATH || path.join(config.distPath, './client', language)
)
}

let nodeModules = {}
fs
.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod
})
.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod
})

module.exports = {
entry: [path.join(config.srcPath, './server/index')],
target: 'node',
output: {
path: path.join(config.distPath, './server'),
filename: 'index.js'
},
externals: nodeModules,
performance: {
hints: false
},
resolve: {
extensions: ['.js', '.jsx'],
alias: config.alias,
modules: [
// places where to search for required modules
config.srcPath,
path.join(config.rootPath, './node_modules')
]
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
use: [
{
loader: 'eslint-loader',
options: {
fix: true
}
}
],
exclude: [/node_modules/]
},
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: [/node_modules/]
}
]
},
plugins: [
new webpack.DefinePlugin(definePluginArgs),
new webpack.BannerPlugin({
banner: config.banner
}),
// NOTE: Server can't process your styles/images/fonts on server-side rendering
new webpack.NormalModuleReplacementPlugin(
/\.(css|sass|less|jpg|png|gif|scss)$/,
'node-noop'
)
// NOTE: @Metnew: If I remember correctly this plugin works similarly to NormalModuleReplacementPlugin
// new webpack.IgnorePlugin(/\.(css|sass|less|jpg|png|gif|scss)$/)
],
node: {
__dirname: true,
global: true
}
entry: [path.join(config.srcPath, './server/index')],
target: 'node',
output: {
path: path.join(config.distPath, './server'),
filename: 'index.js'
},
externals: nodeModules,
performance: {
hints: false
},
resolve: {
extensions: ['.js', '.jsx'],
alias: config.alias,
modules: [
// places where to search for required modules
config.srcPath,
path.join(config.rootPath, './node_modules')
]
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
use: [
{
loader: 'eslint-loader',
options: {
fix: true
}
}
],
exclude: [/node_modules/]
},
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: [/node_modules/]
}
]
},
plugins: [
new webpack.DefinePlugin(definePluginArgs),
new webpack.BannerPlugin({
banner: config.banner
}),
// Server can't process require of your styles/images/fonts
new webpack.NormalModuleReplacementPlugin(
/\.(css|sass|less|jpg|png|gif|scss)$/,
'node-noop'
)
// new webpack.IgnorePlugin(/\.(css|sass|less|jpg|png|gif|scss)$/)
],
node: {
__dirname: true,
global: true
}
}

0 comments on commit 4a57bc3

Please sign in to comment.