@@ -6,49 +6,64 @@ const fs = require('fs');
6
6
7
7
const interval = setInterval ( ( ) => console . log ( 'keepalive' ) , 1000 * 60 * 5 ) ;
8
8
9
- module . exports = {
10
- entry : './src/index.js' ,
11
- output : {
12
- path : path . join ( __dirname , 'dist' ) ,
13
- filename : 'index.js'
14
- } ,
15
- mode : 'development' ,
16
- module : {
17
- rules : [
18
- {
19
- test : / \. c s s $ / ,
20
- use : [ MiniCssExtractPlugin . loader , 'css-loader' ]
21
- }
22
- ]
23
- } ,
24
- plugins : [
25
- new HtmlWebpackPlugin ( {
26
- filename : 'index.html' ,
27
- template : 'src/index.ejs' ,
28
- templateParameters : {
29
- snippets : fs
30
- . readdirSync ( path . join ( __dirname , 'snippets' ) )
31
- . map ( filename =>
32
- path . basename ( filename , path . extname ( filename ) )
33
- ) ,
34
- defaultSnippetName : 'fibonacci' ,
35
- defaultSnippet : fs . readFileSync (
36
- path . join ( __dirname , 'snippets/fibonacci.py' )
9
+ module . exports = ( env = { } ) => {
10
+ const config = {
11
+ entry : './src/index.js' ,
12
+ output : {
13
+ path : path . join ( __dirname , 'dist' ) ,
14
+ filename : 'index.js'
15
+ } ,
16
+ mode : 'development' ,
17
+ resolve : {
18
+ alias : {
19
+ rustpython : path . resolve (
20
+ __dirname ,
21
+ env . rustpythonPkg || '../lib/pkg'
37
22
)
38
23
}
39
- } ) ,
40
- new MiniCssExtractPlugin ( {
41
- filename : 'styles.css'
42
- } ) ,
43
- new WasmPackPlugin ( {
44
- crateDirectory : path . join ( __dirname , '../lib' )
45
- } ) ,
46
- {
47
- apply ( compiler ) {
48
- compiler . hooks . done . tap ( 'clearInterval' , ( ) => {
49
- clearInterval ( interval ) ;
50
- } ) ;
24
+ } ,
25
+ module : {
26
+ rules : [
27
+ {
28
+ test : / \. c s s $ / ,
29
+ use : [ MiniCssExtractPlugin . loader , 'css-loader' ]
30
+ }
31
+ ]
32
+ } ,
33
+ plugins : [
34
+ new HtmlWebpackPlugin ( {
35
+ filename : 'index.html' ,
36
+ template : 'src/index.ejs' ,
37
+ templateParameters : {
38
+ snippets : fs
39
+ . readdirSync ( path . join ( __dirname , 'snippets' ) )
40
+ . map ( filename =>
41
+ path . basename ( filename , path . extname ( filename ) )
42
+ ) ,
43
+ defaultSnippetName : 'fibonacci' ,
44
+ defaultSnippet : fs . readFileSync (
45
+ path . join ( __dirname , 'snippets/fibonacci.py' )
46
+ )
47
+ }
48
+ } ) ,
49
+ new MiniCssExtractPlugin ( {
50
+ filename : 'styles.css'
51
+ } ) ,
52
+ {
53
+ apply ( compiler ) {
54
+ compiler . hooks . done . tap ( 'clearInterval' , ( ) => {
55
+ clearInterval ( interval ) ;
56
+ } ) ;
57
+ }
51
58
}
52
- }
53
- ]
59
+ ]
60
+ } ;
61
+ if ( ! env . noWasmPack ) {
62
+ config . plugins . push (
63
+ new WasmPackPlugin ( {
64
+ crateDirectory : path . join ( __dirname , '../lib' )
65
+ } )
66
+ ) ;
67
+ }
68
+ return config ;
54
69
} ;
0 commit comments