3
3
* webpack. We also rename certain esper files here and move those files
4
4
* into the public directory to be loaded dynamically at runtime by the
5
5
* browser and service workers.
6
- *
6
+ *
7
7
* Note:
8
8
* esper-modern requires modern language plugin to be loaded otherwise it won't
9
9
* work correctly.
10
10
*/
11
- const fs = require ( ' fs-extra' ) ;
12
- const webpack = require ( ' webpack' ) ;
13
- const path = require ( ' path' ) ;
11
+ const fs = require ( " fs-extra" ) ;
12
+ const webpack = require ( " webpack" ) ;
13
+ const path = require ( " path" ) ;
14
14
15
15
// List of esper langauge plugins we want to move into the public directory.
16
- const targets = [
17
- 'lua' ,
18
- 'python' ,
19
- 'coffeescript'
20
- ] ;
21
-
22
- // Get a list of the regular and modern language plugin paths.
23
- const target_paths = targets
24
- . map ( lang => [
25
- [
26
- path . join ( __dirname , 'bower_components' , 'esper.js' , `esper-plugin-lang-${ lang } .js` ) ,
27
- path . join ( __dirname , 'public' , 'javascripts' , 'app' , 'vendor' , `aether-${ lang } .js` )
28
- ] ,
29
- [
30
- path . join ( __dirname , 'bower_components' , 'esper.js' , `esper-plugin-lang-${ lang } -modern.js` ) ,
31
- path . join ( __dirname , 'public' , 'javascripts' , 'app' , 'vendor' , `aether-${ lang } .modern.js` )
32
- ]
33
- ] )
34
- . reduce ( ( l , paths ) => l . concat ( paths ) )
35
-
36
- for ( let [ src , dest ] of target_paths ) {
37
- // const src = path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${target}.js`);
38
- // const dest = path.join(__dirname, 'bower_components', 'aether', 'build', `${target}.js`);
39
- console . log ( `Copy ${ src } , ${ dest } ` ) ;
40
- fs . copySync ( src , dest ) ;
41
- }
16
+ const targets = [ "lua" , "python" , "coffeescript" ] ;
42
17
43
18
const aether_webpack_config = {
44
19
context : path . resolve ( __dirname ) ,
45
20
entry : {
46
- aether : './app/lib/aether/aether.coffee'
21
+ aether : "./app/lib/aether/aether.coffee" ,
22
+ // We need to create the html parser ourselves and move it ourselves into
23
+ // `/javascripts/app/vendor/aether-html.js`
24
+ html : "./app/lib/aether/html.coffee"
47
25
} ,
48
26
output : {
49
- filename : ' ./bower_components/aether/build/aether .js'
27
+ filename : " ./bower_components/aether/build/[name] .js"
50
28
} ,
51
29
module : {
52
30
rules : [
53
31
{
54
32
test : / \. c o f f e e $ / ,
55
- use : [ ' coffee-loader' ]
33
+ use : [ " coffee-loader" ]
56
34
}
57
35
]
58
36
} ,
59
37
resolve : {
60
38
extensions : [ ".coffee" , ".json" , ".js" ]
61
39
} ,
62
40
externals : {
63
- ' esper.js' : ' esper' ,
64
- ' lodash' : '_' ,
65
- ' source-map' : ' SourceMap'
41
+ " esper.js" : " esper" ,
42
+ lodash : "_" ,
43
+ " source-map" : " SourceMap"
66
44
} ,
67
45
68
46
node : {
69
47
fs : "empty"
70
48
}
71
49
} ;
72
50
73
-
74
51
webpack ( aether_webpack_config , function ( err , stats ) {
75
52
if ( err ) {
76
53
console . log ( err ) ;
@@ -79,5 +56,72 @@ webpack(aether_webpack_config, function(err, stats) {
79
56
if ( stats . compilation . errors . length ) {
80
57
console . error ( "Compilation errors:" , stats . compilation . errors ) ;
81
58
}
59
+ copyLanguagesFromEsper ( targets ) ;
82
60
}
83
61
} ) ;
62
+
63
+ function copyLanguagesFromEsper ( targets ) {
64
+ // Get a list of the regular and modern language plugin paths.
65
+ const target_paths = targets
66
+ . map ( lang => [
67
+ [
68
+ path . join (
69
+ __dirname ,
70
+ "bower_components" ,
71
+ "esper.js" ,
72
+ `esper-plugin-lang-${ lang } .js`
73
+ ) ,
74
+ path . join (
75
+ __dirname ,
76
+ "public" ,
77
+ "javascripts" ,
78
+ "app" ,
79
+ "vendor" ,
80
+ `aether-${ lang } .js`
81
+ )
82
+ ] ,
83
+ [
84
+ path . join (
85
+ __dirname ,
86
+ "bower_components" ,
87
+ "esper.js" ,
88
+ `esper-plugin-lang-${ lang } -modern.js`
89
+ ) ,
90
+ path . join (
91
+ __dirname ,
92
+ "public" ,
93
+ "javascripts" ,
94
+ "app" ,
95
+ "vendor" ,
96
+ `aether-${ lang } .modern.js`
97
+ )
98
+ ]
99
+ ] )
100
+ . reduce ( ( l , paths ) => l . concat ( paths ) ) ;
101
+
102
+ for ( let [ src , dest ] of target_paths ) {
103
+ // const src = path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${target}.js`);
104
+ // const dest = path.join(__dirname, 'bower_components', 'aether', 'build', `${target}.js`);
105
+ console . log ( `Copy ${ src } , ${ dest } ` ) ;
106
+ fs . copySync ( src , dest ) ;
107
+ }
108
+
109
+ // Finally copy html as we globally load these within the html iframe.
110
+ const src = path . join (
111
+ __dirname ,
112
+ "bower_components" ,
113
+ "aether" ,
114
+ "build" ,
115
+ "html.js"
116
+ ) ;
117
+ const dest = path . join (
118
+ __dirname ,
119
+ "public" ,
120
+ "javascripts" ,
121
+ "app" ,
122
+ "vendor" ,
123
+ "aether-html.js"
124
+ ) ;
125
+ fs . copySync ( src , dest ) ;
126
+ console . log ( `Copy ${ src } , ${ dest } ` ) ;
127
+ }
0 commit comments