2018-06-07 14:59:05 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
* Author: lengleng (wangiegie@gmail.com)
|
|
|
|
*/
|
|
|
|
|
2018-03-04 13:49:35 +08:00
|
|
|
const webpack = require('webpack')
|
|
|
|
const merge = require('webpack-merge')
|
|
|
|
var config = require('../config')
|
|
|
|
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
|
|
const base = require('./webpack.base.conf')
|
|
|
|
const nodeExternals = require('webpack-node-externals')
|
|
|
|
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
|
|
|
|
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
|
|
|
const utils = require('./utils')
|
|
|
|
module.exports = merge(base, {
|
|
|
|
module: {
|
|
|
|
rules: utils.styleLoaders({
|
|
|
|
sourceMap: config.build.productionSourceMap,
|
|
|
|
extract: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
target: 'node',
|
|
|
|
devtool: '#source-map',
|
|
|
|
entry: './src/entry-server.js',
|
|
|
|
output: {
|
|
|
|
filename: 'server-bundle.js',
|
|
|
|
libraryTarget: 'commonjs2'
|
|
|
|
},
|
|
|
|
// https://webpack.js.org/configuration/externals/#externals
|
|
|
|
// https://github.com/liady/webpack-node-externals
|
|
|
|
externals: nodeExternals({
|
|
|
|
// do not externalize CSS files in case we need to import it from a dep
|
|
|
|
whitelist: /\.css$/
|
|
|
|
}),
|
|
|
|
plugins: [
|
|
|
|
new ExtractTextPlugin({
|
|
|
|
filename: utils.assetsPath('css/[name].[contenthash].css')
|
|
|
|
}),
|
|
|
|
// Compress extracted CSS. We are using this plugin so that possible
|
|
|
|
// duplicated CSS from different components can be deduped.
|
|
|
|
new OptimizeCSSPlugin({
|
|
|
|
cssProcessorOptions: {
|
|
|
|
safe: true
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
|
|
|
|
'process.env.VUE_ENV': '"server"'
|
|
|
|
}),
|
|
|
|
new VueSSRServerPlugin()
|
|
|
|
]
|
|
|
|
})
|