-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
77 lines (74 loc) · 2.04 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
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const meta = require('./package.json');
const production = process.env.NODE_ENV === 'production';
const plugins = [
new webpack.BannerPlugin([
`${meta.name} - ${meta.version}`,
`${meta.homepage}`,
`Copyright 2017 ${meta.author.name}`,
].join('\n')),
new ExtractTextPlugin({
filename: 'app.[hash:8].css',
allChunks: true,
}),
new HtmlWebpackPlugin({
template: `${__dirname}/index.html`,
favicon: 'assets/favicon.ico',
url: process.env.APP_URL || '',
matomoHost: process.env.MATOMO_HOST || null,
matomoId: process.env.MATOMO_ID || null,
}),
new CopyWebpackPlugin([{
from: `${__dirname}/public`
}]),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.GOOGLE_API_KEY': JSON.stringify(process.env.GOOGLE_API_KEY),
}),
];
if (production) {
plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = {
entry: './index.js',
output: {
path: `${__dirname}/dist`,
filename: `app.[hash:8].js`,
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css-loader!autoprefixer-loader!sass-loader'),
},
{
test: /audio\/(.+)\.(wav|mp3|ogg)$/,
loader: 'file-loader',
options: { name: '[path][name].[ext]' },
},
{
test: /icons\/(.+)\.(eot|svg|ttf|woff)$/,
loader: 'file-loader',
options: { name: '[path][name].[ext]' },
},
{
test: /images\/(.+)\.(svg|png|ico)$/,
loader: 'file-loader',
options: { name: '[path][name].[ext]' },
},
],
},
devServer: {
contentBase: `${__dirname}/dist`,
},
plugins,
devtool: production ? undefined : 'source-map',
};