1
- ' use strict' ;
1
+ " use strict" ;
2
2
3
- const webpack = require ( 'webpack' ) ;
4
- const path = require ( 'path' ) ;
5
- const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
6
- const { BundleAnalyzerPlugin} = require ( 'webpack-bundle-analyzer' ) ;
7
- const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
8
- const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
9
- const CopyPlugin = require ( 'copy-webpack-plugin' ) ;
10
- const fs = require ( 'fs' ) ;
3
+ const webpack = require ( "webpack" ) ;
4
+ const path = require ( "path" ) ;
5
+ const HtmlWebpackPlugin = require ( "html-webpack-plugin" ) ;
6
+ const { BundleAnalyzerPlugin } = require ( "webpack-bundle-analyzer" ) ;
7
+ const MiniCssExtractPlugin = require ( "mini-css-extract-plugin" ) ;
8
+ const { CleanWebpackPlugin } = require ( "clean-webpack-plugin" ) ;
9
+ const CopyPlugin = require ( "copy-webpack-plugin" ) ;
10
+ const ESLintPlugin = require ( "eslint-webpack-plugin" ) ;
11
+
12
+ const fs = require ( "fs" ) ;
11
13
12
14
module . exports = {
13
- target : ' web' ,
15
+ target : " web" ,
14
16
15
17
entry : {
16
- app : ' ./webapp/javascript/index.jsx' ,
17
- styles : ' ./webapp/sass/profile.scss' ,
18
+ app : " ./webapp/javascript/index.jsx" ,
19
+ styles : " ./webapp/sass/profile.scss" ,
18
20
} ,
19
21
20
22
output : {
21
- publicPath : '' ,
22
- path : path . resolve ( __dirname , ' ../../webapp/public/build' ) ,
23
- filename : ' [name].[hash].js' ,
23
+ publicPath : "" ,
24
+ path : path . resolve ( __dirname , " ../../webapp/public/build" ) ,
25
+ filename : " [name].[hash].js" ,
24
26
} ,
25
27
26
28
resolve : {
27
- extensions : [ ' .ts' , ' .tsx' , ' .es6' , ' .js' , ' .jsx' , ' .json' , ' .svg' ] ,
29
+ extensions : [ " .ts" , " .tsx" , " .es6" , " .js" , " .jsx" , " .json" , " .svg" ] ,
28
30
alias : {
29
31
// rc-trigger uses babel-runtime which has internal dependency to core-js@2
30
32
// this alias maps that dependency to core-js@t3
31
- ' core-js/library/fn' : ' core-js/stable' ,
33
+ " core-js/library/fn" : " core-js/stable" ,
32
34
} ,
33
35
modules : [
34
- ' node_modules' ,
35
- path . resolve ( ' webapp' ) ,
36
- path . resolve ( ' node_modules' ) ,
36
+ " node_modules" ,
37
+ path . resolve ( " webapp" ) ,
38
+ path . resolve ( " node_modules" ) ,
37
39
] ,
38
40
} ,
39
41
@@ -55,30 +57,30 @@ module.exports = {
55
57
exclude : / n o d e _ m o d u l e s / ,
56
58
use : [
57
59
{
58
- loader : ' babel-loader' ,
60
+ loader : " babel-loader" ,
59
61
options : {
60
62
cacheDirectory : true ,
61
63
babelrc : true ,
62
64
// Note: order is bottom-to-top and/or right-to-left
63
65
presets : [
64
66
[
65
- ' @babel/preset-env' ,
67
+ " @babel/preset-env" ,
66
68
{
67
69
targets : {
68
- browsers : ' last 3 versions' ,
70
+ browsers : " last 3 versions" ,
69
71
} ,
70
- useBuiltIns : ' entry' ,
72
+ useBuiltIns : " entry" ,
71
73
corejs : 3 ,
72
74
modules : false ,
73
75
} ,
74
76
] ,
75
77
[
76
- ' @babel/preset-typescript' ,
78
+ " @babel/preset-typescript" ,
77
79
{
78
80
allowNamespaces : true ,
79
81
} ,
80
82
] ,
81
- ' @babel/preset-react' ,
83
+ " @babel/preset-react" ,
82
84
] ,
83
85
} ,
84
86
} ,
@@ -88,9 +90,9 @@ module.exports = {
88
90
test : / \. j s $ / ,
89
91
use : [
90
92
{
91
- loader : ' babel-loader' ,
93
+ loader : " babel-loader" ,
92
94
options : {
93
- presets : [ [ ' @babel/preset-env' ] ] ,
95
+ presets : [ [ " @babel/preset-env" ] ] ,
94
96
} ,
95
97
} ,
96
98
] ,
@@ -100,7 +102,7 @@ module.exports = {
100
102
exclude : / ( i n d e x | e r r o r ) \. h t m l / ,
101
103
use : [
102
104
{
103
- loader : ' html-loader' ,
105
+ loader : " html-loader" ,
104
106
options : {
105
107
attrs : [ ] ,
106
108
minimize : true ,
@@ -113,81 +115,84 @@ module.exports = {
113
115
{
114
116
test : / \. c s s $ / ,
115
117
// include: MONACO_DIR, // https://github.com/react-monaco-editor/react-monaco-editor
116
- use : [ ' style-loader' , ' css-loader' ] ,
118
+ use : [ " style-loader" , " css-loader" ] ,
117
119
} ,
118
120
{
119
121
test : / \. s c s s $ / ,
120
122
use : [
121
123
MiniCssExtractPlugin . loader ,
122
124
{
123
- loader : ' css-loader' ,
125
+ loader : " css-loader" ,
124
126
options : {
125
127
importLoaders : 2 ,
126
128
url : true ,
127
- sourceMap : true
129
+ sourceMap : true ,
128
130
} ,
129
131
} ,
130
132
{
131
- loader : ' postcss-loader' ,
133
+ loader : " postcss-loader" ,
132
134
options : {
133
135
sourceMap : true ,
134
136
config : { path : __dirname } ,
135
137
} ,
136
138
} ,
137
139
{
138
- loader : ' sass-loader' ,
140
+ loader : " sass-loader" ,
139
141
options : {
140
- sourceMap : true
142
+ sourceMap : true ,
141
143
} ,
142
144
} ,
143
145
] ,
144
146
} ,
145
147
{
146
148
test : / \. ( s v g | i c o | j p g | j p e g | p n g | g i f | e o t | o t f | w e b p | t t f | w o f f | w o f f 2 | c u r | a n i | p d f ) ( \? .* ) ? $ / ,
147
- loader : ' file-loader' ,
148
- options : { name : ' static/img/[name].[hash:8].[ext]' } ,
149
+ loader : " file-loader" ,
150
+ options : { name : " static/img/[name].[hash:8].[ext]" } ,
149
151
} ,
150
152
] ,
151
153
} ,
152
154
153
155
plugins : [
156
+ new ESLintPlugin ( ) ,
154
157
new webpack . ProvidePlugin ( {
155
- $ : ' jquery' ,
156
- jQuery : ' jquery' ,
158
+ $ : " jquery" ,
159
+ jQuery : " jquery" ,
157
160
} ) ,
158
161
new HtmlWebpackPlugin ( {
159
- filename : path . resolve ( __dirname , ' ../../webapp/public/index.html' ) ,
160
- template : path . resolve ( __dirname , ' ../../webapp/templates/index.html' ) ,
162
+ filename : path . resolve ( __dirname , " ../../webapp/public/index.html" ) ,
163
+ template : path . resolve ( __dirname , " ../../webapp/templates/index.html" ) ,
161
164
inject : false ,
162
- chunksSortMode : ' none' ,
165
+ chunksSortMode : " none" ,
163
166
templateParameters : ( compilation , assets , options ) => {
164
- return ( {
165
- extra_metadata : process . env . EXTRA_METADATA ? fs . readFileSync ( process . env . EXTRA_METADATA ) : "" ,
167
+ return {
168
+ extra_metadata : process . env . EXTRA_METADATA
169
+ ? fs . readFileSync ( process . env . EXTRA_METADATA )
170
+ : "" ,
166
171
mode : process . env . NODE_ENV ,
167
172
webpack : compilation . getStats ( ) . toJson ( ) ,
168
173
compilation : compilation ,
169
174
webpackConfig : compilation . options ,
170
175
htmlWebpackPlugin : {
171
176
files : assets ,
172
- options : options
173
- }
174
- } )
177
+ options : options ,
178
+ } ,
179
+ } ;
175
180
} ,
176
181
} ) ,
177
182
new MiniCssExtractPlugin ( {
178
- filename : ' [name].[hash].css' ,
183
+ filename : " [name].[hash].css" ,
179
184
} ) ,
180
185
new webpack . DefinePlugin ( {
181
- PYROSCOPE_VERSION : JSON . stringify ( require ( "../../package.json" ) . version )
186
+ PYROSCOPE_VERSION : JSON . stringify ( require ( "../../package.json" ) . version ) ,
182
187
} ) ,
183
188
new webpack . IgnorePlugin ( / ^ \. \/ l o c a l e $ / , / m o m e n t $ / ) ,
184
189
new CopyPlugin ( {
185
190
patterns : [
186
191
{
187
- from : ' webapp/images' ,
188
- to : ' images'
189
- }
190
- ]
192
+ from : " webapp/images" ,
193
+ to : " images" ,
194
+ } ,
195
+ ] ,
191
196
} ) ,
192
197
] ,
193
198
} ;
0 commit comments