forked from dominiek/moonfish-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
92 lines (87 loc) · 2.48 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractLess = new ExtractTextPlugin({
filename: '[name]-[contenthash].css'
});
const isProduction = process.argv.indexOf('-p') >= 0;
const ENV = isProduction ? 'production' : 'development';
const plugins = [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor-[hash].js',
}),
new webpack.ProvidePlugin({
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
new webpack.DefinePlugin({
ENV: JSON.stringify(ENV),
PRODUCTION_HOSTNAME: JSON.stringify('production.com'),
STAGING_HOSTNAME: JSON.stringify('staging.com'),
'process.env': {
// for react building https://facebook.github.io/react/docs/optimizing-performance.html#use-the-production-build
NODE_ENV: JSON.stringify(ENV)
}
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
// This is necessary to emit hot updates (currently CSS only):
new webpack.HotModuleReplacementPlugin(),
extractLess
];
const app = ['babel-polyfill', './src/index'].filter(Boolean);
module.exports = {
devtool: isProduction ? 'source-maps' : 'cheap-module-source-map',
entry: {
app
},
output: {
publicPath: '/',
path: path.join(__dirname, 'dist'),
filename: '[name].[hash].js',
},
resolve: {
alias: {
'../../theme.config$': path.resolve(path.join(__dirname, 'src'), 'theme/theme.config'),
},
extensions: ['.js', '.json', '.jsx'],
modules: [path.join(__dirname, 'src'), 'node_modules']
},
devServer: {
inline: true,
port: 4000,
historyApiFallback: true
},
module: {
rules: [{
test: /\.jsx?$/,
use: [
'babel-loader',
// !isProduction && 'eslint-loader'
].filter(Boolean),
exclude: /node_modules/,
},
{
test: /\.less$/,
use: extractLess.extract({
fallback: {
loader: 'style-loader'
},
use: ['css-loader', 'less-loader']
}),
}, {
test: /\.(eot|png|jpg|ttf|svg|gif)$/,
use: ['file-loader']
}, {
test: /\.(pdf)$/,
loader: 'file-loader?name=[name].[ext]&outputPath=downloads/&publicPath=downloads/'
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff'
}]
},
plugins
};