ant-design-vue/webpack.site.config.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2019-01-12 11:33:27 +08:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const baseWebpackConfig = require('./webpack.base.config');
2018-01-22 15:47:22 +08:00
2018-01-23 18:55:39 +08:00
module.exports = merge(baseWebpackConfig, {
2018-01-22 15:47:22 +08:00
output: {
2018-04-04 18:39:21 +08:00
path: path.resolve(__dirname, './site-dist'),
2019-02-16 16:51:21 +08:00
publicPath: '/',
filename: '[name].[contenthash:8].js',
chunkFilename: '[contenthash:8].async.js',
2018-01-22 15:47:22 +08:00
},
module: {
rules: [
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
{ loader: 'less-loader', options: { javascriptEnabled: true } },
],
2018-01-22 15:47:22 +08:00
},
2018-01-23 18:55:39 +08:00
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
2018-01-23 18:55:39 +08:00
},
2018-01-22 15:47:22 +08:00
],
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
name: `chunk-vendors`,
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial',
},
common: {
name: `chunk-common`,
minChunks: 2,
priority: -20,
chunks: 'initial',
reuseExistingChunk: true,
},
},
},
},
2018-01-23 18:55:39 +08:00
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
},
}),
new HtmlWebpackPlugin({
2018-04-04 18:39:21 +08:00
template: './site/index.html',
2018-01-23 18:55:39 +08:00
inject: true,
production: true,
}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css',
chunkFilename: '[id].[contenthash:8].css',
2018-01-23 18:55:39 +08:00
}),
],
2019-01-12 11:33:27 +08:00
});