Skip to content

Commit 1205104

Browse files
authored
Merge pull request #382 from meandmax/build-setup-and-fix-jQuery-bug
Make development more convient - fix jQuery reference error
2 parents a2bcf3d + 5b0dd3f commit 1205104

39 files changed

Lines changed: 242 additions & 3635 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ cache:
66
notifications:
77
email: false
88
node_js:
9-
- '4'
9+
- '5.2'
1010
before_install:
11-
- npm i -g npm@^2.0.0
11+
- npm i -g npm@^3.3
1212
before_script:
1313
- npm prune
1414
- 'curl -Lo travis_after_all.py https://git.io/vLSON'

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<p align="center">
3-
<img src="./demo/lory.png" width="200px" />
3+
<img src="./static/lory.png" width="200px" />
44
</p>
55

66
Please visit: [http://meandmax.github.io/lory/](http://meandmax.github.io/lory/ "lory")
@@ -27,8 +27,8 @@ Please visit: [http://meandmax.github.io/lory/](http://meandmax.github.io/lory/
2727
lory is released under the MIT license & supports modern environments.
2828
There is also a prebundled CDN version which you can use.
2929

30-
#### Vanilla JavaScript: https://cdn.jsdelivr.net/lory-js/2.1.0/lory.min.js
31-
#### jQuery plugin: https://cdn.jsdelivr.net/lory-js/2.1.0/jquery.lory.min.js
30+
#### Vanilla JavaScript: https://cdn.jsdelivr.net/lory-js/2.1.0/lory.js
31+
#### jQuery plugin: https://cdn.jsdelivr.net/lory-js/2.1.0/jquery.lory.js
3232

3333
## Install with node:
3434

@@ -79,7 +79,7 @@ npm install
7979
8080
// To start the development server run:
8181
82-
npm start
82+
npm run dev
8383
8484
// To lint your code run:
8585
@@ -180,7 +180,7 @@ li {
180180
## Integration as a jQuery Plugin
181181

182182
```js
183-
<script src="js/jquery.lory.min.js"></script>
183+
<script src="dist/jquery.lory.js"></script>
184184
<script>
185185
'use strict';
186186

@@ -195,7 +195,7 @@ li {
195195
## Integration of multiple sliders on one page
196196

197197
```javascript
198-
<script src="js/lory.js"></script>
198+
<script src="dist/lory.js"></script>
199199
<script>
200200
'use strict';
201201

bin/compile.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import webpack from 'webpack';
2+
import _debug from 'debug';
3+
import fs from 'fs-extra';
4+
import config from '../webpack.config.prod.js';
5+
6+
const debug = _debug('app:build:webpack-compiler');
7+
8+
const DEFAULT_STATS_FORMAT = {
9+
chunks : false,
10+
chunkModules : false,
11+
colors : true
12+
}
13+
14+
function webpackCompiler (webpackConfig, statsFormat = DEFAULT_STATS_FORMAT) {
15+
return new Promise((resolve, reject) => {
16+
const compiler = webpack(webpackConfig);
17+
18+
compiler.run((err, stats) => {
19+
const jsonStats = stats.toJson();
20+
21+
debug('Webpack compile completed.');
22+
debug(stats.toString(statsFormat));
23+
24+
if (err) {
25+
debug('Webpack compiler encountered a fatal error.', err);
26+
return reject(err);
27+
} else if (jsonStats.errors.length > 0) {
28+
debug('Webpack compiler encountered errors.');
29+
debug(jsonStats.errors.join('\n'));
30+
return reject(new Error('Webpack compiler encountered errors'));
31+
} else if (jsonStats.warnings.length > 0) {
32+
debug('Webpack compiler encountered warnings.');
33+
debug(jsonStats.warnings.join('\n'));
34+
} else {
35+
debug('No errors or warnings encountered.');
36+
}
37+
resolve(jsonStats);
38+
});
39+
});
40+
}
41+
42+
;(async function () {
43+
try {
44+
debug('Run compiler');
45+
const stats = await webpackCompiler(config);
46+
if (stats.warnings.length && config.compiler_fail_on_warning) {
47+
debug('Config set to fail on warning, exiting with status code "1".');
48+
process.exit(1);
49+
}
50+
} catch (e) {
51+
debug('Compiler encountered an error.', e);
52+
process.exit(1);
53+
}
54+
})();

bin/server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import webpack from 'webpack';
2+
import config from '../webpack.config.dev.js';
3+
import WebpackDevServer from 'webpack-dev-server';
4+
5+
config.entry.app.unshift("webpack-dev-server/client?http://localhost:8080/", "webpack/hot/dev-server");
6+
const compiler = webpack(config);
7+
const server = new WebpackDevServer(compiler, {
8+
hot: true
9+
});
10+
11+
server.listen(8080);

demo/custom-index.html

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)