forked from nhn/tui.image-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
124 lines (121 loc) · 3.53 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
/**
* webpack.config.js created on 2016. 12. 01.
* @author NHN Ent. FE Development Lab <[email protected]>
*/
const pkg = require('./package.json');
const path = require('path');
const webpack = require('webpack');
const SafeUmdPlugin = require('safe-umd-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizaeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const isProduction = process.argv.indexOf('-p') > -1;
const FILENAME = pkg.name + (isProduction ? '.min' : '');
const BANNER = [
`${FILENAME}.js`,
`@version ${pkg.version}`,
`@author ${pkg.author}`,
`@license ${pkg.license}`
].join('\n');
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: './src/index.js',
output: {
library: ['tui', 'ImageEditor'],
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist'),
publicPath: '/dist',
filename: `${FILENAME}.js`
},
externals: [{
'tui-code-snippet': {
'commonjs': 'tui-code-snippet',
'commonjs2': 'tui-code-snippet',
'amd': 'tui-code-snippet',
'root': ['tui', 'util']
},
'tui-color-picker': {
'commonjs': 'tui-color-picker',
'commonjs2': 'tui-color-picker',
'amd': 'tui-color-picker',
'root': ['tui', 'colorPicker']
},
'fabric': {
'commonjs': ['fabric', 'fabric'],
'commonjs2': ['fabric', 'fabric'],
'amd': 'fabric',
'root': 'fabric'
}
}],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
enforce: 'pre',
options: {
failOnWarning: false,
failOnError: false
}
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?cacheDirectory',
options: {
babelrc: true
}
}, {
test: /\.styl$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'stylus-loader',
options: {
sourceMap: true
}
}
]
}, {
test: /\.svg$/,
loader: 'svg-inline-loader'
}
]
},
plugins: [
new webpack.BannerPlugin(BANNER),
new MiniCssExtractPlugin({
filename: `${FILENAME}.css`
}),
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
}
};