Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit 665ce2c

Browse files
committed
Add webpack support
1 parent 3b54786 commit 665ce2c

File tree

5 files changed

+128
-3
lines changed

5 files changed

+128
-3
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<script type="text/javascript">
2323
requirejs.config({
2424
baseUrl: 'lib',
25-
paths: { i18n: '../scripts/i18n', text: '../scripts/text' }
25+
paths: { i18n: '../scripts/i18n', raw: '../scripts/text' }
2626
});
2727

2828
var modules = [ 'gcli/index', 'gcli/items/demo', 'gcli/test/index' ];

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
"dryice": "^0.4.11",
1313
"es6-promise": "^2.0.1",
1414
"express": "^4.11.1",
15-
"jsdom": "^3.0.2",
15+
"jsdom": "=3.1.2",
16+
"json-loader": "^0.5.2",
1617
"morgan": "^1.5.1",
18+
"node-libs-browser": "^0.5.2",
19+
"raw-loader": "^0.5.1",
1720
"socket.io": "^1.3.2",
18-
"socket.io-client": "^1.3.2"
21+
"socket.io-client": "^1.3.2",
22+
"webpack": "^1.9.11"
1923
},
2024
"author": "Joe Walker <[email protected]>",
2125
"main": "lib/gcli",

webpack.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2012, Mozilla Foundation and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
/* eslint no-var: 0 */
19+
20+
var path = require('path');
21+
var webpack = require('webpack');
22+
23+
module.exports = {
24+
entry: {
25+
'wp-index': [ './wp-index.js' ],
26+
},
27+
output: {
28+
path: path.join(__dirname, 'built'),
29+
filename: '[name].js',
30+
sourceMapFilename: '[file].map',
31+
publicPath: 'http://localhost:3000/',
32+
},
33+
module: {
34+
loaders: [
35+
{ test: /\.css$/, loader: 'raw' },
36+
{ test: /\.html$/, loader: 'raw' },
37+
{ test: /\.json/, loader: 'json' },
38+
],
39+
},
40+
plugins: [
41+
new webpack.IgnorePlugin(/jsdom$/),
42+
new webpack.IgnorePlugin(/fs$/),
43+
new webpack.IgnorePlugin(/express$/),
44+
new webpack.IgnorePlugin(/child_process$/),
45+
new webpack.IgnorePlugin(/body-parser$/),
46+
new webpack.IgnorePlugin(/^text!gcli/),
47+
],
48+
};
49+
50+
var compiler = webpack(module.exports);
51+
52+
compiler.run(function(err, stats) {
53+
if (err) {
54+
throw new Error(err);
55+
}
56+
57+
console.log(stats.toString({ colors: true }));
58+
59+
//stats.compilation.errors
60+
// .map(function(s) { return s.message; })
61+
// .forEach(console.log);
62+
//stats.compilation.warnings
63+
// .map(function(s) { return s.message; })
64+
// .forEach(console.log);
65+
});

wp-index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="author" content="Joe Walker">
6+
<title>GCLI: Graphical Command Line</title>
7+
<style type="text/css" media="screen">
8+
body {
9+
width: 100%; height: 100%; overflow: hidden;
10+
}
11+
#gcli-root {
12+
position: absolute; top: 0; bottom: 0; left: 0; right: 0;
13+
}
14+
</style>
15+
</head>
16+
17+
<body class="light">
18+
19+
<div id="gcli-root"></div>
20+
21+
</body>
22+
23+
<script type="text/javascript" src="built/wp-index.js"></script>
24+
</html>

wp-index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2012, Mozilla Foundation and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var gcli = require('./lib/gcli/index');
20+
var demo = require('./lib/gcli/items/demo');
21+
var test = require('./lib/gcli/test/index');
22+
23+
// Add the commands/types/converters as required
24+
var system = gcli.createSystem();
25+
system.addItems(gcli.items); // Common infrastructure: types, etc
26+
system.addItems(gcli.commandItems); // Common set of useful commands
27+
system.addItems(demo.items); // Extra demo commands
28+
29+
gcli.createTerminal(system).then(function(terminal) {
30+
terminal.language.showIntro(); // Intro text
31+
test.run(terminal, false); // Run the unit test at each startup
32+
}).catch(console.error.bind(console));

0 commit comments

Comments
 (0)