Skip to content

Commit 751de15

Browse files
committed
Build regular and minified versions
1 parent 6b1e124 commit 751de15

14 files changed

+68
-21
lines changed
File renamed without changes.

demo/example-embedded.html examples/example-embedded.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Chat-UI | Example - Embedded</title>
6-
<script async src="../lib/chat-ui.js"></script>
6+
<script src="../lib/chat-ui.js"></script>
77
<link href="../lib/chat-ui.css" rel="stylesheet" media="all" />
88

99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/darkula.min.css">
@@ -118,10 +118,6 @@ <h3>Embedded chat</h3>
118118

119119
chat.on('user-send-message', chatMessage);
120120

121-
chat.on('chat-closed', function(data) {
122-
console.log('chat-closed', data);
123-
chatIcon.style.display = 'block';
124-
});
125121
});
126122
</code>
127123
</pre>
@@ -191,11 +187,6 @@ <h3>Embedded chat</h3>
191187
chat.trigger('add-phrase', '<img src="./smile-hi.gif">');
192188

193189
chat.on('user-send-message', chatMessage);
194-
195-
chat.on('chat-closed', function(data) {
196-
console.log('chat-closed', data);
197-
chatIcon.style.display = 'block';
198-
});
199190
});
200191
</script>
201192
</body>

demo/example-themes.html examples/example-themes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Chat-UI | Example - Themes</title>
6-
<script async src="../lib/chat-ui.js"></script>
6+
<script src="../lib/chat-ui.js"></script>
77
<link href="../lib/chat-ui.css" rel="stylesheet" media="all" />
88

99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/darkula.min.css">
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

gulpfile.babel.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import gutil from 'gulp-util';
33
import less from 'gulp-less';
44
import rename from 'gulp-rename';
55
import webpack from 'webpack';
6+
import del from 'del';
7+
import cleanCSS from 'gulp-clean-css';
68
import webpackConfig from './webpack.config';
79
import yargs from 'yargs';
810

@@ -15,8 +17,16 @@ const args = yargs
1517
}
1618
}).argv;
1719

20+
let libFilename = 'chat-ui';
21+
let buildTasks = ['js', 'less'];
22+
1823
if (args.pack) {
1924
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}, mangle: false}));
25+
webpackConfig.output.filename = libFilename + '.min.js';
26+
buildTasks.unshift('clean');
27+
buildTasks.push('minify-css');
28+
} else {
29+
webpackConfig.output.filename = libFilename + '.js';
2030
}
2131

2232
const compiler = webpack(webpackConfig);
@@ -61,7 +71,7 @@ gulp.task('js-watch', () => {
6171
});
6272
});
6373

64-
gulp.task('less', () => {
74+
gulp.task('less', ['clean'], () => {
6575
const errorHandling = function(err) {
6676
// Handle less errors, but do not stop watch task
6777
gutil.log(gutil.colors.red.bold('[Less error]'));
@@ -96,9 +106,26 @@ gulp.task('less', () => {
96106
.pipe(gulp.dest('./lib'));
97107
});
98108

109+
gulp.task('minify-css', ['clean', 'less'], function() {
110+
return gulp.src('lib/*.css')
111+
.pipe(cleanCSS({compatibility: 'ie8'}))
112+
.pipe(rename({
113+
suffix: '.min'
114+
}))
115+
.pipe(gulp.dest('lib'));
116+
});
117+
118+
gulp.task('clean', function(callback) {
119+
del([
120+
'lib/*.css'
121+
]).then(function() {
122+
callback();
123+
});
124+
});
125+
99126
gulp.task('less-watch', () => {
100127
gulp.watch('./source/less/**/*.less', ['less']);
101128
});
102129

103-
gulp.task('build', ['js', 'less']);
130+
gulp.task('build', buildTasks);
104131
gulp.task('watch', ['js-watch', 'less', 'less-watch']);

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "Chat UI",
55
"main": "index.js",
66
"scripts": {
7-
"build": "gulp build",
8-
"pack": "gulp build --pack",
7+
"build": "gulp build && gulp build --pack",
98
"watch": "gulp watch",
109
"eslint": "./node_modules/eslint/bin/eslint.js ./source/**/*.js",
1110
"postinstall": "cp -i hooks/pre-commit.sh .git/hooks/pre-commit",
@@ -30,12 +29,14 @@
3029
"babel-preset-es2015": "^6.9.0",
3130
"babel-register": "^6.9.0",
3231
"bean": "^1.0.15",
32+
"del": "^2.2.0",
3333
"eslint": "^2.10.2",
3434
"eslint-config-airbnb": "^9.0.1",
3535
"eslint-plugin-import": "^1.8.0",
3636
"eslint-plugin-jsx-a11y": "^1.2.2",
3737
"eslint-plugin-react": "^5.1.1",
3838
"gulp": "^3.9.1",
39+
"gulp-clean-css": "^2.0.8",
3940
"gulp-less": "^3.1.0",
4041
"gulp-rename": "^1.2.2",
4142
"gulp-util": "^3.0.7",

readme-ru.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@
66

77
![alt tag](https://github.com/artemdemo/chat-ui/blob/master/img/chat-themes.png)
88

9-
### Разработка
9+
### Технологии
1010

1111
* ES6
1212
* Babel
1313
* Webpack
1414
* Gulp
1515
* Less
1616

17-
### Code quality
17+
### Разработка
18+
19+
Watch function for all files
20+
21+
```bash
22+
$ npm run watch
23+
```
24+
25+
Build regular and minified versions of the library files.
26+
27+
```bash
28+
$ npm run build
29+
```
30+
31+
### Качество кода
1832

1933
* eslint, based on airbnb specs
2034

readme.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@ Module for Chat UI representation
66

77
![alt tag](https://github.com/artemdemo/chat-ui/blob/master/img/chat-themes.png)
88

9-
### Developing
9+
### Technologies
1010

1111
* ES6
1212
* Babel
1313
* Webpack
1414
* Gulp
1515
* Less
1616

17+
### Developing
18+
19+
Watch function for all files
20+
21+
```bash
22+
$ npm run watch
23+
```
24+
25+
Build regular and minified versions of the library files.
26+
27+
```bash
28+
$ npm run build
29+
```
30+
1731
### Code quality
1832

1933
* eslint, based on airbnb specs

source/components/mainFrame.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const mainFrame = () => {
3737
]
3838
}
3939
};
40+
const openChatClass = `${LIB_NAME}-mainframe_open`;
4041

4142
const updateContainer = (containerName, newElement) => {
4243
if (mainFrameParts.indexOf(containerName) > -1) {
@@ -47,8 +48,6 @@ export const mainFrame = () => {
4748
};
4849

4950
const addEvents = (mainFrameEl) => {
50-
const openChatClass = `${LIB_NAME}-mainframe_open`;
51-
5251
eventEmitter.on(CLOSE_CHAT, (data) => {
5352
const closeSource = data && data.source ? data.source : CHAT_CLOSED_SOURCE_CHAT;
5453
domHelper.removeClass(mainFrameEl, openChatClass);

webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
devtool: 'source-map',
66
output: {
77
path: __dirname + '/lib/',
8-
filename: 'chat-ui.js',
8+
// filename will be added in gulpfile
9+
// filename: 'chat-ui.js',
910
library: 'ChatUI',
1011
libraryTarget: 'umd',
1112
umdNamedDefine: true

0 commit comments

Comments
 (0)