webpack.server.config.js 946 B

123456789101112131415161718192021222324252627282930313233
  1. const webpack = require('webpack')
  2. const merge = require('webpack-merge')
  3. const base = require('./webpack.base.config')
  4. const nodeExternals = require('webpack-node-externals')
  5. const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
  6. module.exports = merge(base, {
  7. target: 'node',
  8. devtool: '#source-map',
  9. entry: './src/entry-server.js',
  10. output: {
  11. filename: 'server-bundle.js',
  12. libraryTarget: 'commonjs2'
  13. },
  14. resolve: {
  15. alias: {
  16. 'create-api': './create-api-server.js'
  17. }
  18. },
  19. // https://webpack.js.org/configuration/externals/#externals
  20. // https://github.com/liady/webpack-node-externals
  21. externals: nodeExternals({
  22. // do not externalize CSS files in case we need to import it from a dep
  23. whitelist: /\.css$/
  24. }),
  25. plugins: [
  26. new webpack.DefinePlugin({
  27. 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
  28. 'process.env.VUE_ENV': '"server"'
  29. }),
  30. new VueSSRServerPlugin()
  31. ]
  32. })