-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.babel.js
130 lines (121 loc) · 2.99 KB
/
webpack.config.babel.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import autoprefixer from 'autoprefixer';
import SWPrecacheWebpackPlugin from 'sw-precache-webpack-plugin';
import FaviconsWebpackPlugin from 'favicons-webpack-plugin';
const ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: './src/index.jsx',
output: {
path: './build',
publicPath: '',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.jsx', '.js', '.json', '.less']
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
exclude: /src\//,
loader: 'source-map'
}
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.(less|css)$/,
loader: ExtractTextPlugin.extract('css?sourceMap!postcss!less?sourceMap')
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(xml|html|txt)$/,
loader: 'raw'
},
{
test: /\.(svg|woff|ttf|eot)(\?.*)?$/i,
loader: 'file-loader?name=assets/fonts/[name]_[hash:base64:5].[ext]'
}
]
},
postcss: () => [
autoprefixer({ browsers: 'last 2 versions' })
],
plugins: ([
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('style.css', { allChunks: true }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(ENV)
}),
new HtmlWebpackPlugin({
template: 'src/index.template.html'
})
]).concat(ENV === 'production' ? [
new FaviconsWebpackPlugin({
logo: './src/assets/spiro-logo.png',
prefix: 'icons/',
// Generate a cache file with control hashes and
// don't rebuild the favicons until those hashes change
persistentCache: true,
// Inject the html into the html-webpack-plugin
inject: true,
// favicon background color (see https://github.com/haydenbleasel/favicons#usage)
background: '#fff',
// favicon app title (see https://github.com/haydenbleasel/favicons#usage)
title: 'Spiro3D',
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: true,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: true
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new SWPrecacheWebpackPlugin(
{
cacheId: 'Spiro3D',
filename: 'spiro3D_SW.js',
maximumFileSizeToCacheInBytes: 4194304,
minify: true,
runtimeCaching: [{
handler: 'cacheFirst',
urlPattern: /[.]mp3$/,
}],
}
),
] : []),
stats: { colors: true },
devtool: ENV === 'production' ? 'source-map' : 'inline-source-map',
devServer: {
port: process.env.PORT || 8080,
host: '0.0.0.0',
colors: true,
publicPath: '/',
contentBase: './src',
historyApiFallback: true,
proxy: [
// OPTIONAL: proxy configuration:
// {
// path: '/optional-prefix/**',
// target: 'http://target-host.com',
// rewrite: req => { req.url = req.url.replace(/^\/[^\/]+\//, ''); } // strip first path segment
// }
]
}
};