webpack.server.conf.js 1.19 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');

let webpackConfig = merge(baseConfig, {
  entry: {
    app: './apps/entry-server.js',
  },
  target: 'node',
  resolve: {
    alias: {
      'create-api': 'common/create-api-server.js',
      'report-error': 'common/report-error-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;