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