-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
108 lines (102 loc) · 2.76 KB
/
Copy pathwebpack.config.dev.js
File metadata and controls
108 lines (102 loc) · 2.76 KB
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
107
108
import path from 'path';
import webpack from 'webpack';
import cssModulesValues from 'postcss-modules-values';
import {getDotenv} from '../src/universal/utils/dotenv';
import HappyPack from 'happypack';
// Import .env and expand variables:
getDotenv();
const root = process.cwd();
const clientInclude = [path.join(root, 'src', 'client'), path.join(root, 'src', 'universal')];
const globalCSS = path.join(root, 'src', 'universal', 'styles', 'global');
const srcDir = path.join(root, 'src');
const prefetches = [
'react-dnd/lib/index.js',
'joi/lib/index.js',
'universal/modules/kanban/containers/Kanban/KanbanContainer.js'
];
const prefetchPlugins = prefetches.map(specifier => new webpack.PrefetchPlugin(specifier));
const babelQuery = {
plugins: [
['transform-decorators-legacy'],
['react-transform', {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}, {
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}]
}]
]
};
export default {
// devtool: 'source-maps',
devtool: 'eval',
context: srcDir,
entry: {
app: [
'babel-polyfill',
'react-hot-loader/patch',
'client/client.js',
'webpack-hot-middleware/client'
]
},
output: {
// https://github.com/webpack/webpack/issues/1752
filename: 'app.js',
chunkFilename: '[name]_[chunkhash].js',
path: path.join(root, 'build'),
publicPath: '/static/'
},
plugins: [
...prefetchPlugins,
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'__CLIENT__': true,
'__PRODUCTION__': false,
'process.env.NODE_ENV': JSON.stringify('development')
}),
new HappyPack({
loaders: ['babel'],
threads: 4
})
],
resolve: {
extensions: ['.js'],
modules: [srcDir, 'node_modules']
},
// used for joi validation on client
node: {
dns: 'mock',
net: 'mock'
},
postcss: [cssModulesValues],
module: {
loaders: [
{test: /\.json$/, loader: 'json-loader'},
{test: /\.txt$/, loader: 'raw-loader'},
{test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/, loader: 'url-loader?limit=10000'},
{test: /\.(eot|ttf|wav|mp3)$/, loader: 'file-loader'},
{
test: /\.css$/,
loader: 'style!css',
include: globalCSS
},
{
test: /\.css$/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[name]_[local]_[hash:base64:5]!postcss',
exclude: globalCSS,
include: clientInclude
},
{
test: /\.js$/,
loader: 'happypack/loader',
query: babelQuery,
include: clientInclude
}
]
}
};