html2canvas/webpack.config.js

88 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-07-29 05:07:42 +03:00
const webpack = require('webpack');
2017-08-06 13:13:40 +03:00
const fs = require('fs');
const path = require('path');
2017-12-03 12:07:10 +03:00
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
2017-08-06 13:13:40 +03:00
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json')));
const banner =
`${pkg.title} ${pkg.version} <${pkg.homepage}>
Copyright (c) ${(new Date()).getFullYear()} ${pkg.author.name} <${pkg.author.url}>
Released under ${pkg.license} License`;
2017-07-29 05:07:42 +03:00
2017-08-06 19:26:09 +03:00
const plugins = [
new webpack.DefinePlugin({
'__DEV__': true,
'__VERSION__': JSON.stringify(pkg.version)
}),
new webpack.BannerPlugin(banner)
];
const modules = {
rules: [{
2017-08-06 19:26:09 +03:00
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
2017-07-29 05:07:42 +03:00
};
2017-08-06 19:26:09 +03:00
module.exports = [
{
mode: 'development',
2017-08-06 19:26:09 +03:00
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'html2canvas.js',
2017-08-06 19:26:09 +03:00
library: 'html2canvas',
libraryExport: 'default',
2017-08-06 19:26:09 +03:00
libraryTarget: 'umd'
},
module: modules,
plugins
},
2017-12-03 12:07:10 +03:00
{
mode: 'production',
2017-12-03 12:07:10 +03:00
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'html2canvas.min.js',
2017-12-03 12:07:10 +03:00
library: 'html2canvas',
libraryExport: 'default',
2017-12-03 12:07:10 +03:00
libraryTarget: 'umd'
},
module: modules,
2017-12-09 13:00:45 +03:00
plugins: [
new webpack.DefinePlugin({
'__DEV__': false,
'__VERSION__': JSON.stringify(pkg.version)
}),
new UglifyJSPlugin(),
new webpack.BannerPlugin(banner)
]
2017-12-03 12:07:10 +03:00
},
2017-08-06 19:26:09 +03:00
{
mode: 'production',
2017-08-06 19:26:09 +03:00
entry: './src/renderer/RefTestRenderer.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'RefTestRenderer.js',
2017-08-06 19:26:09 +03:00
library: 'RefTestRenderer',
libraryExport: 'default',
2017-08-06 19:26:09 +03:00
libraryTarget: 'umd'
},
module: modules,
plugins
2017-08-08 19:50:31 +03:00
},
{
mode: 'production',
2017-08-08 19:50:31 +03:00
entry: './tests/testrunner.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'testrunner.js',
2017-08-08 19:50:31 +03:00
library: 'testrunner',
libraryTarget: 'umd'
},
module: modules,
plugins
2017-08-06 19:26:09 +03:00
}
];