text: 'use strict'
  const path = require('path')
  const utils = require('./utils')
  const webpack = require('webpack')
  const config = require('../config')
  const merge = require('webpack-merge')
  const baseWebpackConfig = require('./webpack.base.conf')
  const CopyWebpackPlugin = require('copy-webpack-plugin')
  const HtmlWebpackPlugin = require('html-webpack-plugin')
  const ExtractTextPlugin = require('extract-text-webpack-plugin')
  const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  const nodeExternals = require('webpack-node-externals')
  const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
  
  const env = require('../config/prod.env')
  
  const webpackConfig = merge(baseWebpackConfig, {
      entry: './src/server.js',
      target: 'node',
      module: {
          rules: utils.styleLoaders({
              sourceMap: config.build.productionSourceMap,
              extract: true,
              usePostCSS: true
          })
      },
      devtool: config.build.productionSourceMap ? config.build.devtool : false,
      output: {
          path: config.build.assetsRoot,
          filename: utils.assetsPath('js/[name].[chunkhash].js'),
          chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'),
          libraryTarget: 'commonjs2'
      },
      externals: nodeExternals({
          // 不要外置化 webpack 需要处理的依赖模块。
          // 你可以在这里添加更多的文件类型。例如，未处理 *.vue 原始文件，
          // 你还应该将修改 `global`（例如 polyfill）的依赖模块列入白名单
          whitelist: /\.css$/
      }),
      plugins: [
          new VueSSRServerPlugin(),
          // http://vuejs.github.io/vue-loader/en/workflow/production.html
          new webpack.DefinePlugin({
              'process.env': env
          }),
          new UglifyJsPlugin({
              uglifyOptions: {
                  compress: {
                      warnings: false
                  }
              },
              sourceMap: config.build.productionSourceMap,
              parallel: true
          }),
          // extract css into its own file
          new ExtractTextPlugin({
              filename: utils.assetsPath('css/[name].[contenthash].css'),
              allChunks: true
          }),
          // Compress extracted CSS. We are using this plugin so that possible
          // duplicated CSS from different components can be deduped.
          new OptimizeCSSPlugin({
              cssProcessorOptions: config.build.productionSourceMap ? { safe: true, map: { inline: false } } : { safe: true }
          }),
          // keep module.id stable when vendor modules does not change
          new webpack.HashedModuleIdsPlugin(),
          // enable scope hoisting
          new webpack.optimize.ModuleConcatenationPlugin(),
          // copy custom static assets
          new CopyWebpackPlugin([
              {
                  from: path.resolve(__dirname, '../static'),
                  to: config.build.assetsSubDirectory,
                  ignore: ['.*']
              }
          ])
      ]
  })
  
  module.exports = webpackConfig
  