Skip to content

Commit

Permalink
commonjs webpackconfig for require support from npm
Browse files Browse the repository at this point in the history
  • Loading branch information
ivictbor committed Jun 28, 2017
1 parent e289561 commit ec800fb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 41 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ typings/
.idea

# custom
build/painterro.js
build/painterro.js.map

build/painterro.*
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

[GitHub](https://github.com/ivictbor/painterro) | [npm](https://www.npmjs.com/package/painterro)

Painterro is singlefile JavaScript paint component which allows to edit images directly in browser.
It can be easily integrated into your website or blog by including only one `painterro.js` file and calling init code.

With Painterro you can:
- Paste image from clipboard (for example screenshot)
- Crop image by defined area
- Paint lines and rectangles (alpha color can be used)
- Paint primitives (alpha color can be used)
- Add text
- Rotate / Resize image

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

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "painterro",
"version": "0.1.3",
"version": "0.1.4",
"description": "Embуedded html image editor",
"main": "build/painterro.js",
"main": "build/painterro.commonjs2.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --optimize-minimize --progress",
Expand Down
81 changes: 46 additions & 35 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
var path = require('path');
var webpack = require('webpack');

module.exports = {
entry: './js/main.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'painterro.js',
library: 'Painterro', // export as library
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']

function webpackConfig(target) {
return {
entry: './js/main.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: `painterro.${target == 'var' && '' || target}.js`,
library: 'Painterro', // export as library
libraryTarget: target
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
},
{
test: /\.(ttf|woff|woff2|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader"
}
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
},
{
test: /\.(ttf|woff|woff2|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader"
}
]
},
stats: {
colors: true
},
]
},
stats: {
colors: true
},

devtool: 'source-map',
devServer: {
disableHostCheck: true
devtool: 'source-map',
devServer: {
disableHostCheck: true
}
}
};
}

module.exports = [
webpackConfig('var'),
webpackConfig('commonjs2'),
webpackConfig('amd'),
webpackConfig('umd')
];

0 comments on commit ec800fb

Please sign in to comment.