Skip to content

Commit ec800fb

Browse files
committed
commonjs webpackconfig for require support from npm
1 parent e289561 commit ec800fb

4 files changed

Lines changed: 54 additions & 41 deletions

File tree

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,4 @@ typings/
6060
.idea
6161

6262
# custom
63-
build/painterro.js
64-
build/painterro.js.map
65-
63+
build/painterro.*

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
2+
[GitHub](https://github.com/ivictbor/painterro) | [npm](https://www.npmjs.com/package/painterro)
3+
14
Painterro is singlefile JavaScript paint component which allows to edit images directly in browser.
25
It can be easily integrated into your website or blog by including only one `painterro.js` file and calling init code.
36

47
With Painterro you can:
58
- Paste image from clipboard (for example screenshot)
69
- Crop image by defined area
7-
- Paint lines and rectangles (alpha color can be used)
10+
- Paint primitives (alpha color can be used)
811
- Add text
12+
- Rotate / Resize image
913

1014
![Painterro preview](https://raw.githubusercontent.com/ivictbor/painterro/master/docs/preview.png)
1115

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "painterro",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "Embуedded html image editor",
5-
"main": "build/painterro.js",
5+
"main": "build/painterro.commonjs2.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"build": "webpack --optimize-minimize --progress",

webpack.config.js

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,52 @@
11
var path = require('path');
22
var webpack = require('webpack');
33

4-
module.exports = {
5-
entry: './js/main.js',
6-
output: {
7-
path: path.resolve(__dirname, 'build'),
8-
filename: 'painterro.js',
9-
library: 'Painterro', // export as library
10-
},
11-
module: {
12-
loaders: [
13-
{
14-
test: /\.js$/,
15-
loader: 'babel-loader',
16-
query: {
17-
presets: ['es2015']
4+
5+
function webpackConfig(target) {
6+
return {
7+
entry: './js/main.js',
8+
output: {
9+
path: path.resolve(__dirname, 'build'),
10+
filename: `painterro.${target == 'var' && '' || target}.js`,
11+
library: 'Painterro', // export as library
12+
libraryTarget: target
13+
},
14+
module: {
15+
loaders: [
16+
{
17+
test: /\.js$/,
18+
loader: 'babel-loader',
19+
query: {
20+
presets: ['es2015']
21+
}
22+
},
23+
{
24+
test: /\.css$/,
25+
use: [
26+
{ loader: "style-loader" },
27+
{ loader: "css-loader" }
28+
]
29+
},
30+
{
31+
test: /\.(ttf|woff|woff2|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
32+
loader: "url-loader"
1833
}
19-
},
20-
{
21-
test: /\.css$/,
22-
use: [
23-
{ loader: "style-loader" },
24-
{ loader: "css-loader" }
25-
]
26-
},
27-
{
28-
test: /\.(ttf|woff|woff2|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
29-
loader: "url-loader"
30-
}
31-
]
32-
},
33-
stats: {
34-
colors: true
35-
},
34+
]
35+
},
36+
stats: {
37+
colors: true
38+
},
3639

37-
devtool: 'source-map',
38-
devServer: {
39-
disableHostCheck: true
40+
devtool: 'source-map',
41+
devServer: {
42+
disableHostCheck: true
43+
}
4044
}
41-
};
45+
}
46+
47+
module.exports = [
48+
webpackConfig('var'),
49+
webpackConfig('commonjs2'),
50+
webpackConfig('amd'),
51+
webpackConfig('umd')
52+
];

0 commit comments

Comments
 (0)