forked from quran/quran.com-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
92 lines (89 loc) · 3.2 KB
/
webpack.prod.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
require('dotenv').config({path: (process.env.NODE_ENV || 'production') + '.env'});
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var IsomorphicPlugin = require('webpack-isomorphic-tools/plugin')
var webpackIsomorphicToolsPlugin = new IsomorphicPlugin(require('./webpack-isomorphic-tools-configuration'));
var relativeAssetsPath = './static/dist';
var assetsPath = path.join(__dirname, relativeAssetsPath);
module.exports = {
output: {
path: assetsPath,
publicPath: process.env.USE_LOCAL_ASSETS ? '/public/' : '//assets-1f14.kxcdn.com/',
filename: '[name]-[hash].js'
},
debug: false,
target: 'web',
cache: false,
entry: [
'bootstrap-sass!./bootstrap-sass.config.js',
'./client.js',
],
stats: {
colors: true,
reasons: false
},
resolve: {
extensions: ['', '.js'],
alias: {
'styles': __dirname + '/src/styles',
'components': __dirname + '/src/scripts/components',
'actions': __dirname + '/src/scripts/actions',
'stores': __dirname + '/src/scripts/stores',
'constants': __dirname + '/src/scripts/constants',
'mixins': __dirname + '/src/scripts/mixins',
'configs': __dirname + '/src/scripts/configs',
'utils': __dirname + '/src/scripts/utils'
}
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{
test: /\.(js|jsx)$/,
exclude: [/server/, /node_modules/, /tests/],
loader: 'babel'
},
{ test: /\.json$/, loader: 'json-loader'},
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?name=images/[name].[ext]&limit=10240' }
]
},
plugins: [
new CleanPlugin([relativeAssetsPath]),
new webpack.NoErrorsPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"windows.jQuery": "jquery"
}),
new ExtractTextPlugin("[name]-[hash].css", {allChunks: true}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env': JSON.stringify({
BROWSER: true,
API_URL: process.env.API_URL,
CURRENT_URL: process.env.CURRENT_URL,
NODE_ENV: process.env.NODE_ENV
}),
__SERVER__: false,
__CLIENT__: true,
__DEVELOPMENT__: false,
__DEVTOOLS__: false
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
webpackIsomorphicToolsPlugin
]
};