-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.server.js
107 lines (103 loc) · 3.31 KB
/
webpack.server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const config = require('./webpack.base');
const glob = require('glob');
const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');
// const CleanWebpackPlugin = require('clean-webpack-plugin');
// const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
// const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
// const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
// const smp = new SpeedMeasurePlugin();
// const isAnalyze = process.env.npm_config_argv.includes('analyze');
// const HtmlWebpackPlugins = glob.sync('src/page/*/index.html').map((v) => {
// const name = v.replace(/src\/page\/(.*)\/index.html/ig, '$1');
// return new HtmlWebpackPlugin({
// filename: `/page/${name}.html`,
// template: v,
// chunks: [`page/${name}`],
// favicon: path.join(__dirname, '/src/assets/images/bitbug_favicon.ico'),
// })
// });
const HtmlWebpackPlugins = [];
let result = {
entry: {
page: './server/app.js'
},
target: 'node',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'distServer'),
filename: '[name].js',
publicPath: '/'
},
mode: "development",
externals: {
zepto: "zepto",
},
module: {
rules: [{
test: /\.tsx?$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'server')
],
loader: ["awesome-typescript-loader", ]
},
{
test: /\.jsx?/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'server')
],
use: ['babel-loader', ]
}, {
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
]
}, {
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'less-loader',
]
},
]
},
// optimization: {
// minimizer: [
// new UglifyJsPlugin({
// cache: true,
// parallel: true,
// sourceMap: false, // set to true if you want JS source maps
// }),
// new OptimizeCssAssetsPlugin({})
// ]
// },
resolve: {
extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'],
},
plugins: HtmlWebpackPlugins.concat([
// new LodashModuleReplacementPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
'process.env': {
NODE_ENV: JSON.stringify('production'),
}
}),
// new CleanWebpackPlugin(['dist']),
]),
}
// if (isAnalyze) {
// result = smp.wrap(result);
// }
module.exports = result;