-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
104 lines (96 loc) · 2.38 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
99
100
101
102
103
104
const webpack = require('webpack');
const path = require('path');
const isDevEnv = process.env.NODE_ENV != 'production';
const isProdEnv = process.env.NODE_ENV == 'production';
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
var config = {
mode: 'production',
devtool: 'source-maps',
entry: {
'terminalizer': [
'./src/js/index.js',
'./src/css/terminalizer.css'
],
'terminalizer.min': [
'./src/js/index.js',
'./src/css/terminalizer.css'
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].js',
library: 'webpackNumbers',
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
include: /\.min\.js$/
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.min\.css$/,
cssProcessorOptions: {
map: {
inline: false,
annotation: true
}
}
})
]
},
externals: {
jquery: {
commonjs: 'jquery',
commonjs2: 'jquery',
amd: 'jquery',
root: '$'
},
xterm: {
commonjs: ['xterm', 'Terminal'],
commonjs2: ['xterm', 'Terminal'],
amd: ['xterm', 'Terminal'],
root: 'Terminal'
}
},
plugins: [
new CleanWebpackPlugin(['./dist'], {verbose: false}),
new MiniCssExtractPlugin({filename: 'css/[name].css'}),
new webpack.NoEmitOnErrorsPlugin()
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{loader: 'babel-loader', options: {presets: ['@babel/preset-env']}}
]
},
{
test: /\.css$/,
use: [
{loader: MiniCssExtractPlugin.loader},
{loader: 'css-loader'},
{loader: 'postcss-loader', options: {plugins: [require('autoprefixer')]}}
],
}
]
}
};
// Apply the configurations for the development environment
if (isDevEnv) {
// Configurations
config.mode = 'development';
config.devtool = 'eval';
// Remove .min files
delete config.entry['terminalizer.min'];
}
module.exports = config;