-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
51 lines (48 loc) · 2 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
const path = require('path')
const webpack = require('webpack')
const BundleTracker = require('webpack-bundle-tracker')
const CompressionPlugin = require("compression-webpack-plugin");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var BUILD_DIR = path.resolve(__dirname, 'bundle');
var APP_DIR = path.resolve(__dirname, 'client/app/js');
var config = {
entry: APP_DIR + '/index.jsx',
output: {
path: BUILD_DIR,
filename: 'bundle.js',
publicPath: '/client/app'
},
devServer: {
historyApiFallback: true,
contentBase: '.',
hot: true
},
externals: {
'Config': JSON.stringify(process.env.ENV === 'production' ? {
url: "use this url in production"
} : {
url: "use this url in development"
})
},
plugins: [
new webpack.DefinePlugin({'process.env.NODE_ENV': JSON.stringify('development')}),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new CompressionPlugin({asset: "[path].gz[query]",algorithm: "gzip",test: /\.js$|\.css$|\.html$/,threshold: 10240,minRatio: 0}),
new BundleTracker({filename: './webpack-stats.json'}),
new webpack.ProvidePlugin({ $: 'jquery',jQuery: 'jquery','window.jQuery': 'jquery', 'React' : 'react', 'ReactDOM':'react-dom' , 'Config' : 'Config'}),
],
module: {
loaders: [
{test: /\.jsx?$/,exclude: /node_modules/,loader: 'babel-loader', query: {plugins: ['transform-runtime'],presets: ['env','react'],}},
{test: /\.css$/,use: ExtractTextPlugin.extract({fallback: 'style-loader',use: 'css-loader?modules,localIdentName="[name]-[local]-[hash:base64:10]"'}),},
{test: /\.scss$/,loader: "style-loader!css-loader!sass-loader?sourceMap"},
{test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000'},
]
},
resolve: {
modules: ['./','node_modules'],
extensions: ['.js', '.jsx', '.json','.css','.scss','.ttf','.eot','.woff','.woff2']
}
};
module.exports = config;