1- const webpack = require ( 'webpack' ) ;
21const path = require ( 'path' ) ;
32const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
4-
53const pkg = require ( './package.json' ) ;
64
7- const plugins = [
8- // 로더들에게 옵션을 넣어주는 플러그인
9- new webpack . LoaderOptionsPlugin ( {
10- minimize : true ,
11- } ) ,
12- ] ;
135module . exports = {
146 mode : 'production' ,
157 entry : {
@@ -27,45 +19,20 @@ module.exports = {
2719 libraryTarget : 'umd' ,
2820 umdNamedDefine : true ,
2921 publicPath : './' ,
22+ globalObject : 'this' , // node/browser 호환성
3023 } ,
3124 module : {
3225 rules : [
3326 {
3427 test : / \. ( j s | j s x | t s x | t s ) $ / ,
35- loader : 'babel-loader?cacheDirectory' ,
36- include : path . resolve ( __dirname , 'src' ) ,
28+ loader : 'babel-loader' ,
3729 options : {
30+ cacheDirectory : true ,
3831 presets : [
39- [
40- '@babel/preset-env' ,
41- {
42- modules : false ,
43- useBuiltIns : 'usage' ,
44- corejs : 3 ,
45- targets : { browsers : [ 'last 5 versions' , 'ie >= 11' ] , node : 'current' } ,
46- } ,
47- ] ,
48- '@babel/preset-react' ,
49- [
50- '@babel/preset-typescript' ,
51- {
52- isTSX : true ,
53- allExtensions : true ,
54- allowDeclareFields : true ,
55- } ,
56- ] ,
32+ /* 네가 쓰던 preset들 그대로 */
5733 ] ,
5834 plugins : [
59- '@babel/plugin-transform-runtime' ,
60- [ '@babel/plugin-transform-typescript' , { allowDeclareFields : true } ] ,
61- [ '@babel/plugin-proposal-class-properties' , { loose : true } ] ,
62- [ '@babel/plugin-proposal-private-methods' , { loose : true } ] ,
63- [ '@babel/plugin-proposal-decorators' , { legacy : true } ] ,
64- [ '@babel/plugin-proposal-private-property-in-object' , { loose : true } ] ,
65- '@babel/plugin-syntax-dynamic-import' ,
66- '@babel/plugin-syntax-async-generators' ,
67- '@babel/plugin-proposal-object-rest-spread' ,
68- 'dynamic-import-webpack' ,
35+ /* 네가 쓰던 plugin들 그대로 */
6936 ] ,
7037 } ,
7138 exclude : / n o d e _ m o d u l e s / ,
@@ -75,38 +42,27 @@ module.exports = {
7542 use : [ 'style-loader' , 'css-loader' , 'less-loader' ] ,
7643 } ,
7744 {
78- test : / \. ( i c o | p n g | j p g | j p e g | g i f | s v g | w o f f | w o f f 2 | t t f | e o t ) ( \? v = [ 0 - 9 ] \. [ 0 - 9 ] \. [ 0 - 9 ] ) ? $ / ,
79- loader : 'url-loader' ,
80- options : {
81- publicPath : './' ,
82- name : 'fonts/[hash].[ext]' ,
83- limit : 10000 ,
84- } ,
45+ test : / \. ( i c o | p n g | j p g | j p e g | g i f | s v g | w o f f | w o f f 2 | t t f | e o t ) $ / ,
46+ type : 'asset' ,
47+ parser : { dataUrlCondition : { maxSize : 10 * 1024 } } ,
48+ generator : { filename : 'fonts/[hash][ext]' } ,
8549 } ,
8650 ] ,
8751 } ,
8852 resolve : {
89- extensions : [ '.ts' , '.tsx' , '.js' , 'jsx' ] ,
53+ extensions : [ '.ts' , '.tsx' , '.js' , '. jsx' ] ,
9054 } ,
9155 optimization : {
56+ minimize : true ,
9257 minimizer : [
9358 new TerserPlugin ( {
9459 include : / \. m i n \. j s $ / ,
95- cache : true ,
96- parallel : true ,
97- sourceMap : false ,
9860 terserOptions : {
99- warnings : false ,
100- compress : {
101- warnings : false ,
102- unused : true , // tree shaking(export된 모듈 중 사용하지 않는 모듈은 포함하지않음)
103- } ,
10461 ecma : 6 ,
62+ compress : { unused : true } ,
10563 mangle : true ,
106- unused : true ,
10764 } ,
10865 } ) ,
10966 ] ,
11067 } ,
111- plugins,
11268} ;
0 commit comments