forked from devforth/painterro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
78 lines (73 loc) · 1.65 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const path = require('path');
const webpack = require('webpack');
require('es6-promise').polyfill();
function webpackConfig(target) {
let filename;
if (target === 'var') {
filename = `painterro-${require('./package.json').version}.min.js`
} else if (target === 'var-latest') {
filename = 'painterro.min.js';
target = 'var';
} else {
filename = `painterro.${target}.js`;
}
return {
entry: './js/main.js',
output: {
path: path.resolve(__dirname, 'build'),
filename,
library: 'Painterro', // export as library
libraryTarget: target,
},
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
},
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'es2016']
}
},
{
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
},
devtool: 'source-map',
devServer: {
disableHostCheck: true
}
}
}
const isDevServer = process.argv.find(v => v.includes('webpack-dev-server'));
if (!isDevServer) {
module.exports = [
webpackConfig('var'),
webpackConfig('var-latest'),
webpackConfig('commonjs2'),
webpackConfig('amd'),
webpackConfig('umd')
];
} else {
module.exports = [
webpackConfig('var-latest'),
];
}