-
Notifications
You must be signed in to change notification settings - Fork 115
/
webpack.config.js
66 lines (64 loc) · 2.19 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
module.exports = (env) => {
// eslint-disable-next-line
env = env || {};
const tag = env.TAG_NAME || process.env.TAG_NAME || 'dev';
const hasTag = typeof tag !== 'undefined' && tag !== '';
const gitRevisionPlugin = new GitRevisionPlugin();
return {
node: {
fs: 'empty',
},
plugins: [
new webpack.ProvidePlugin({
$: 'zepto-webpack',
}),
new HtmlWebpackPlugin({
template: './tests/tests.html',
filename: 'index.html',
chunks: ['tests'],
}),
new HtmlWebpackPlugin({
template: './tests/playground.html',
filename: 'playground.html',
chunks: ['playground'],
}),
new CopyPlugin([{ from: 'static/*', flatten: true }], {
// Always copy (for --watch / webpack-dev-server). Needed
// because CleanWebpackPlugin wipes everything out.
copyUnmodified: true,
}),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(env.NODE_ENV),
__VERSION: JSON.stringify(gitRevisionPlugin.version()),
__COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
__BRANCH: JSON.stringify(gitRevisionPlugin.branch()),
}),
],
devtool: tag === 'prod' ? 'hidden-source-map' : false,
entry: {
main: './src/main.js',
div: './src/div.js',
tests: './tests/tests.coffee',
playground: './tests/playground.js',
},
output: {
library: 'vextab',
libraryTarget: 'umd',
filename: hasTag ? `[name].${tag}.js` : '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{ test: /\.jsx?$/, exclude: /node_modules/, use: [{ loader: 'babel-loader' }, { loader: 'eslint-loader', options: { fix: true } }] },
{ test: /\.coffee$/, use: [{ loader: 'coffee-loader' }] },
{ test: /\.jison$/, use: [{ loader: 'jison-loader' }] },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
],
},
};
};