Skip to content

Instantly share code, notes, and snippets.

@gHashTag
Created May 4, 2018 13:51
Show Gist options
  • Select an option

  • Save gHashTag/be6a214505a1c56e0ccbc75c5de7e8d7 to your computer and use it in GitHub Desktop.

Select an option

Save gHashTag/be6a214505a1c56e0ccbc75c5de7e8d7 to your computer and use it in GitHub Desktop.
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ENV = process.env
const isProduction = ENV.NODE_ENV === 'production'
const client = {
entry: './index.js',
output: {
path:__dirname +'/build',
filename: 'index_bundle.js'
},
devtool: isProduction
? 'source-map'
: 'eval-source-map' ,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
},
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
}
const server = {
entry: './server/index.js',
target: 'node',
output: {
path:__dirname +'/build',
filename: 'server.js'
},
devtool: isProduction
? 'source-map'
: 'eval-source-map' ,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
},
},
],
},
]
}
}
module.exports = [ client, server ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment