forked from SSShooter/mind-elixir-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (94 loc) · 2.3 KB
/
webpack.config.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
const path = require('path')
// const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
// .BundleAnalyzerPlugin
let config = {
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'ts-loader',
},
},
{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'less-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{ test: /\.svg/, type: 'asset/inline' },
// {
// test: /\.(ttf|woff|woff2|eot|svg)$/i,
// use: [
// {
// loader: 'url-loader',
// options: {
// limit: false,
// },
// },
// ],
// },
],
},
}
module.exports = (env, argv) => {
if (argv.mode === 'development') {
console.log('development', env)
config = {
...config,
entry: env.dist !== '0' ? './src/dev.dist.js' : './src/dev.ts',
plugins: [
new HtmlWebpackPlugin({
title: 'MindElixir',
template: 'src/index.html',
}),
],
}
}
if (argv.mode === 'production') {
console.log('production')
config = {
...config,
entry: {
MindElixir: './src/index.ts',
MindElixirLite: './src/index.lite.ts',
example1: './src/exampleData/1.js',
example2: './src/exampleData/2.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
},
// plugins: [
// new BundleAnalyzerPlugin()
// ],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
},
},
}),
],
},
}
}
// plugins: [new webpack.optimize.ModuleConcatenationPlugin()], // scope hoist
return config
}