1+ const path = require ( 'path' ) ;
2+ const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
3+
4+ module . exports = {
5+ entry : "./src/Main.ts" ,
6+ mode : process . env . NODE_ENV . trim ( ) == 'production' ? 'production' : 'development' ,
7+ output : {
8+ path : path . resolve ( __dirname , 'dist' ) ,
9+ filename : 'static/js/[name].js' ,
10+ library : {
11+ name : 'Contribute' ,
12+ type : 'window' ,
13+ } ,
14+ } ,
15+
16+ // Enable sourcemaps for debugging webpack's output.
17+ // devtool: "source-map",
18+
19+ resolve : {
20+ extensions : [ '.ts' , '.tsx' , '.js' , '.jsx' , '.scss' ] ,
21+ modules : [ 'node_modules' ]
22+ } ,
23+
24+ module : {
25+ rules : [
26+ // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
27+ {
28+ test : / \. t s x ? $ / ,
29+ exclude : / n o d e _ m o d u l e s / ,
30+ use : "ts-loader"
31+ } ,
32+ // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
33+ {
34+ enforce : 'pre' ,
35+ test : / \. j s $ / ,
36+ loader : "source-map-loader"
37+ } ,
38+ {
39+ test : / i n d e x .h t m l | m e t a 3 d .j s | b a s i s _ t r a n s c o d e r .j s | d r a c o _ d e c o d e r .j s | d r a c o _ e n c o d e r .j s / ,
40+ type : 'asset/inline' ,
41+ generator : {
42+ dataUrl : content => {
43+ return content . toString ( )
44+ }
45+ }
46+ } ,
47+ // {
48+ // test: /meta3d.js/,
49+ // type: 'asset/inline',
50+ // generator: {
51+ // dataUrl: content => {
52+ // return content.toString()
53+ // }
54+ // }
55+ // },
56+ // {
57+ // test: /basis_transcoder.js/,
58+ // type: 'asset/inline',
59+ // generator: {
60+ // dataUrl: content => {
61+ // return content.toString()
62+ // }
63+ // }
64+ // },
65+ // {
66+ // test: /draco_decoder.js/,
67+ // type: 'asset/inline',
68+ // generator: {
69+ // dataUrl: content => {
70+ // return content.toString()
71+ // }
72+ // }
73+ // },
74+ // {
75+ // test: /draco_encoder.js/,
76+ // type: 'asset/inline',
77+ // generator: {
78+ // dataUrl: content => {
79+ // return content.toString()
80+ // }
81+ // }
82+ // },
83+ ]
84+ } ,
85+ plugins : [
86+ /**
87+ * All files inside webpack's output.path directory will be removed once, but the
88+ * directory itself will not be. If using webpack 4+'s default configuration,
89+ * everything under <PROJECT_DIR>/dist/ will be removed.
90+ * Use cleanOnceBeforeBuildPatterns to override this behavior.
91+ *
92+ * During rebuilds, all webpack assets that are not used anymore
93+ * will be removed automatically.
94+ *
95+ * See `Options and Defaults` for information
96+ */
97+ new CleanWebpackPlugin ( ) ,
98+ // new HtmlWebpackPlugin({
99+ // template: './user.html',
100+ // filename: 'user.html',
101+ // }),
102+ ] ,
103+ // When importing a module whose path matches one of the following, just
104+ // assume a corresponding global variable exists and use that instead.
105+ // This is important because it allows us to avoid bundling all of our
106+ // dependencies, which allows browsers to cache those libraries between builds.
107+ externals : {
108+ }
109+ } ;
0 commit comments