2019-03-27 18:10:50 +00:00
|
|
|
const { resolve } = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
const nodeExternals = require('webpack-node-externals')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const CreateFileWebpack = require('create-file-webpack')
|
2019-09-22 18:01:43 +00:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
|
2019-03-27 18:10:50 +00:00
|
|
|
|
|
|
|
const serverConfig = {
|
|
|
|
entry: './src/server.js',
|
|
|
|
target: 'node',
|
|
|
|
externals: [nodeExternals()],
|
|
|
|
output: {
|
|
|
|
path: resolve(__dirname, 'build'),
|
|
|
|
filename: 'server.js',
|
|
|
|
publicPath: '/'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: [
|
|
|
|
'babel-loader'
|
|
|
|
],
|
|
|
|
exclude: '/node_modules/'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
2019-09-22 18:01:43 +00:00
|
|
|
modules: {
|
|
|
|
localIdentName: '[name]__[local]___[hash:base64:5]'
|
|
|
|
},
|
|
|
|
onlyLocals: true,
|
|
|
|
importLoaders: 2
|
2019-03-27 18:10:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 10000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__isBrowser__: 'false'
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin(),
|
2019-09-22 18:01:43 +00:00
|
|
|
new CleanWebpackPlugin(),
|
2019-03-27 18:10:50 +00:00
|
|
|
new CreateFileWebpack({
|
2019-11-17 14:06:53 +00:00
|
|
|
path: './',
|
2019-03-27 18:10:50 +00:00
|
|
|
fileName: 'data.json',
|
|
|
|
content: JSON.stringify({
|
|
|
|
'posts': [],
|
|
|
|
'other': {}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = serverConfig
|