forked from NikolayRys/Likely
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
69 lines (62 loc) · 1.88 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
/* eslint-env node */
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const packageJson = require('./package.json');
const { NODE_ENV } = process.env;
const isProduction = NODE_ENV === 'production';
const license = `Likely $version by Ilya Birman (ilyabirman.net)
Rewritten sans jQuery by Evgeny Steblinsky (volter9.github.io)
Supported by Ivan Akulov (iamakulov.com), Viktor Karpov (https://twitter.com/vitkarpov),
Nikolay Rys (linkedin.com/in/nikolay-rys) and contributors
Inspired by Social Likes by Artem Sapegin (sapegin.me)`;
function getLicenseComment(version) {
return license.replace(/\$version/g, version);
}
const plugins = [
new ExtractTextPlugin({
filename: './release/likely.css',
disable: false,
}),
];
if (isProduction) {
plugins.push(
new webpack.BannerPlugin({
banner: getLicenseComment(packageJson.version),
exclude: /\.css$/,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
})
);
}
module.exports = {
entry: {
likely: './source/likely.js',
// [] is a workaround, see https://github.com/webpack/webpack/issues/300
'likely-commonjs': ['./source/index.js'],
},
output: {
filename: './release/[name].js',
library: 'likely',
libraryTarget: 'umd',
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
}, {
test: /\.styl$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader!stylus-loader',
}),
}],
},
devtool: false,
watch: !isProduction,
plugins,
};