This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.prod.js
76 lines (74 loc) · 2.25 KB
/
webpack.config.prod.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
import webpack from 'webpack';
import path from 'path';
import poststylus from 'poststylus';
import autoprefixer from 'autoprefixer';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import DotenvPlugin from 'webpack-dotenv-plugin';
import chalk from 'chalk';
import ProgressBarPlugin from 'progress-bar-webpack-plugin';
const GLOBALS = {
'process.env.NODE_ENV': JSON.stringify('production')
};
export default {
debug: true,
devtool: 'source-map',
noInfo: false,
entry: './src/index',
target: 'web',
output: {
path: path.join(__dirname, '/temp-dist'),
publicPath: '/',
filename: 'assets/js/bundle.js'
},
devServer: {
contentBase: './dist'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin(GLOBALS),
new ExtractTextPlugin('assets/css/styles.css'),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin(),
new ProgressBarPlugin({
format: `Status [:bar] ${chalk.green.bold(':percent')} :msg (:elapsed seconds)`,
clear: false
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new DotenvPlugin({
sample: './.env.sample',
path: './.env'
})
],
resolve: {
modulesDirectories: ['node_modules', './src'],
extensions: ['', '.js', '.jsx', '.css', '.styl'],
alias: {
'~assets': path.join(__dirname, 'src/assets'),
'~bower': path.join(__dirname, 'bower_components'),
'~const': path.join(__dirname, 'src/constants'),
'~global': path.join(__dirname, 'src/modules/_global'),
'~modules': path.join(__dirname, 'src/modules'),
'~reducers': path.join(__dirname, 'src/reducers'),
'~utils': path.join(__dirname, 'src/utils')
}
},
module: {
loaders: [
{ test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: 'babel' },
{ test: /(\.css)$/, loader: ExtractTextPlugin.extract('css?sourceMap') },
{ test: /\.styl$/, loader: ExtractTextPlugin.extract('css-loader!stylus-loader') },
{ test: /\.(png|jpe?g|ico|gif)$/, loader: 'url-loader?limit=1000&name=assets/img/[name].[ext]' },
{ test: /\.(otf|woff|woff2|svg|ttf|eot)(\?[\s\S]+)?$/, loader: 'file-loader?limit=1000&name=assets/fonts/[name].[ext]' }
]
},
stylus: {
use: [
poststylus([
autoprefixer({ browsers: ['last 2 version', '> 1%', 'IE > 8'] })
])
]
}
};