forked from nhn/tui.calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
129 lines (127 loc) · 3.64 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* eslint-env es6 */
/* eslint strict: 0, no-process-env: 0 */
var pkg = require('./package.json');
var path = require('path');
var webpack = require('webpack');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var OptimizaeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var SafeUmdPlugin = require('safe-umd-webpack-plugin');
var isProduction = process.env.NODE_ENV === 'production';
var FILENAME = pkg.name + (isProduction ? '.min' : '');
var BANNER = [
'TOAST UI Calendar',
'@version ' + pkg.version + ' | ' + new Date().toDateString(),
'@author ' + pkg.author,
'@license ' + pkg.license
].join('\n');
var context = JSON.stringify({
CSS_PREFIX: 'tui-full-calendar-',
BUNDLE_TYPE: (isProduction ? 'Release' : 'Debug')
});
var preprocessLoader = `preprocess-loader?${context}`;
var devtool = 'source-map';
module.exports = {
entry: './src/index.js',
output: {
library: ['tui', 'Calendar'],
libraryTarget: 'umd',
path: path.join(__dirname, 'dist'),
filename: FILENAME + '.js',
publicPath: '/dist'
},
externals: {
'tui-code-snippet': {
'commonjs': 'tui-code-snippet',
'commonjs2': 'tui-code-snippet',
'amd': 'tui-code-snippet',
'root': ['tui', 'util']
},
'tui-date-picker': {
'commonjs': 'tui-date-picker',
'commonjs2': 'tui-date-picker',
'amd': 'tui-date-picker',
'root': ['tui', 'DatePicker']
},
'tui-time-picker': {
'commonjs': 'tui-time-picker',
'commonjs2': 'tui-time-picker',
'amd': 'tui-time-picker',
'root': ['tui', 'TimePicker']
}
},
module: {
rules: [{
test: /\.hbs$/,
use: 'handlebars-template-loader'
}, {
test: /\.styl$/,
use: [
MiniCssExtractPlugin.loader,
preprocessLoader,
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'stylus-loader',
options: {
sourceMap: true
}
}
]
}, {
test: /\.js$/,
use: [
preprocessLoader,
{
loader: 'eslint-loader',
options: {
failOnError: isProduction,
cache: !isProduction
}
}
],
exclude: /node_modules|bower_components/
}, {
test: /\.(gif|png|jpe?g)$/,
use: 'url-loader'
}]
},
devtool,
plugins: [
new MiniCssExtractPlugin({
filename: FILENAME + '.css'
}),
new webpack.BannerPlugin({
banner: BANNER,
entryOnly: true
}),
new SafeUmdPlugin()
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true
}),
new OptimizaeCSSAssetsPlugin({
cssProcessorOptions: {
map: {
inline: false
}
}
})
]
},
devServer: {
historyApiFallback: false,
progress: true,
inline: true,
host: '0.0.0.0',
disableHostCheck: true
}
};