-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
94 lines (90 loc) · 2.96 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
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
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpack = require('webpack');
var assetsPath = path.join(__dirname, 'public', 'assets');
var publicPath = 'assets/';
var commonLoaders = [
{ test: /(\.js$|\.jsx$)/, loader: 'jsx-loader?harmony' },
{ test: /\.png$/, loader: 'url-loader' },
// Copy precomposed image files over to assets path
{ test: /.*precomposed\.png$/, loader: 'file-loader?name=images/[name].[ext]'},
{ test: /\.jpg$/, loader: 'file-loader' }
];
module.exports = [
{
// The configuration for the client
name: 'browser',
/* The entry point of the bundle
* Entry points for multi page app could be more complex
* A good example of entry points would be:
* entry: {
* pageA: './pageA',
* pageB: './pageB',
* pageC: './pageC',
* adminPageA: './adminPageA',
* adminPageB: './adminPageB',
* adminPageC: './adminPageC'
* }
*
* We can then proceed to optimize what are the common chunks
* plugins: [
* new CommonsChunkPlugin('admin-commons.js', ['adminPageA', 'adminPageB']),
* new CommonsChunkPlugin('common.js', ['pageA', 'pageB', 'admin-commons.js'], 2),
* new CommonsChunkPlugin('c-commons.js', ['pageC', 'adminPageC']);
* ]
*/
entry: {
app: './app/app.js'
},
output: {
// The output directory as absolute path
path: assetsPath,
// The filename of the entry chunk as relative path inside the output.path directory
filename: '[name].js',
// The output path from the view of the Javascript
publicPath: publicPath
},
module: {
preLoaders: [{
test: /\.js$|.jsx$/,
exclude: /node_modules/,
loaders: ['eslint', 'jscs']
}],
loaders: commonLoaders.concat([
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.scss$/,
loader: ExtractTextPlugin.extract('css?sourceMap!sass?sourceMap&outputStyle=expanded' +
'&includePaths[]=' + (path.resolve(__dirname, './bower_components')) +
'&includePaths[]=' + (path.resolve(__dirname, './node_modules')))
}
])
},
plugins: [
// extract inline css from modules into separate files
new ExtractTextPlugin('styles/main.css')
]
}, {
// The configuration for the server-side rendering
name: 'server-side rendering',
entry: {
app: './app/app.js'
},
target: 'node',
output: {
// The output directory as absolute path
path: assetsPath,
// The filename of the entry chunk as relative path inside the output.path directory
filename: '[name].server.js',
// The output path from the view of the Javascript
publicPath: publicPath,
libraryTarget: 'commonjs2'
},
externals: /^[a-z\-0-9]+$/,
module: {
loaders: commonLoaders
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/\.(css|scss)$/, 'node-noop')
]
}
];