webpack.server.conf.js 1.25 KB
const webpack = require('webpack');
const merge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin');
let baseConfig = require('./webpack.base.conf');
const pkg = require('../package.json');
const isProd = process.env.NODE_ENV === 'production';

let webpackConfig = merge(baseConfig, {
  entry: {
    app: './apps/entry-server.js'
  },
  devtool: isProd ? 'source-map' : 'cheap-module-source-map',
  target: 'node',
  resolve: {
    alias: {
      'create-api': 'common/create-api-server.js'
    }
  },
  module: {
    rules: [
      {
        test: /\.s?css$/,
        use: 'ignore-loader'
      }, {
        test: /\.styl(us)?$/,
        use: 'ignore-loader'
      }, {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        use: 'ignore-loader'
      }, {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        use: 'ignore-loader'
      }
    ]
  },
  output: {
    libraryTarget: 'commonjs2',
  },
  externals: nodeExternals({
    whitelist: [/cube-ui/]
  }),
  plugins: [
    new VueSSRServerPlugin({
      filename: '../../manifest.server.json'
    }),
    new webpack.DefinePlugin({
      'process.env.VUE_ENV': '"server"'
    })
  ]
});

module.exports = webpackConfig;