-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
106 lines (98 loc) · 2.64 KB
/
webpack.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
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
/* eslint-disable */
require('dotenv').config()
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const postcssConfig = require('./postcss.config')
/* eslint-enable */
const PATHS = {
src: path.join(__dirname, 'src'),
app: path.join(__dirname, 'src', 'client', 'app.js'),
dist: path.join(__dirname, 'dist', 'js'),
}
const webpackconfig = {
entry: {
app: [
PATHS.app,
],
},
output: {
path: PATHS.dist,
filename: 'bundle.js', // Output name of bundle
publicPath: '/',
},
module: {
loaders: [
{
test: /\.js$/, // Javascript loader
include: PATHS.src,
exclude: /node_modules/,
loader: 'babel',
query: {
cacheDirectory: false,
presets: ['es2015', 'es2016', 'react'],
plugins: [
'babel-plugin-transform-object-rest-spread', // Adds ... spread operator for objects
'babel-plugin-transform-class-properties', // Adds support for React classes
'transform-class-properties', // Annoymous functions
],
},
},
{
test: /\.css/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract(
'style',
'css?sourceMap&modules&&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss'
),
},
{
test: /\.scss/,
include: /react-toolbox/,
loader: ExtractTextPlugin.extract(
'style',
'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass'
),
},
],
},
postcss: () => postcssConfig,
sassLoader: {
data: '@import "shared/styles/main.scss";',
includePaths: [PATHS.src],
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: true,
compress: {
warnings: true,
unused: true,
dead_code: true,
drop_console: true,
comparisons: true,
conditionals: true,
},
mangle: {
screw_ie8: true,
keep_fnames: true,
},
}),
new ExtractTextPlugin('../common.css', {
allChunks: true,
}),
new webpack.DefinePlugin({ 'process.env': {
NODE_ENV: JSON.stringify('production'),
IMAGE_STORAGE_URL: JSON.stringify(process.env.IMAGE_STORAGE_URL),
} }),
],
}
const complier = webpack(webpackconfig)
/* eslint-disable */
complier.run((err, stats) => {
console.log(err)
console.log(stats)
})
/* eslint-enable */