-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (88 loc) · 2.88 KB
/
webpack.config.js
File metadata and controls
91 lines (88 loc) · 2.88 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
var webpack = require('webpack');
var myArgs = process.argv.slice(2);
var isHot = myArgs.indexOf('--hot') !== -1;
console.log('is hot: ' + isHot);
var additionalPlugins = isHot ? [ 'react-hmre' ] : [];
var path = require("path");
const assert = require('assert');
const HandlebarsPlugin = require('handlebars-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
assert(process.env.ENV_SERVER_PORT, 'Error! ENV_SERVER_PORT is empty!');
assert(process.env.ENV_SERVER_HOST, 'Error! ENV_SERVER_HOST is empty!');
const port = isHot ? '8080' : process.env.ENV_SERVER_PORT;
const host = process.env.ENV_SERVER_HOST;
var productionPlugins = isHot ? [] : [
new webpack.optimize.UglifyJsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
},
}),
];
module.exports = [
{
name: 'client side, output to ./server/client',
context: __dirname + '/src',
entry: {
home: './js/shkola.js',
vendor: [
'bootstrap', 'bootstrap-less', 'jquery', 'classie',
'react', 'react-dom', 'react-redux', 'react-modal', 'react-router', 'react-google-maps',
'redux',
],
// webpack: 'webpack/hot/dev-server',
},
output: {
path: __dirname + '/server/client',
filename: 'bundle.js',
publicPath: `${host}:${port}/assets/`,
},
plugins: productionPlugins.concat([
new HandlebarsPlugin({
entry: path.join(process.cwd(), "src", "index.hbs"),
output: path.join(process.cwd(), "server", "client", "index.html"),
data: { bundleHost: `${host}:${port}/assets/` },
}),
new ExtractTextPlugin('bundle.css'),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
]),
styleLoader:
require('extract-text-webpack-plugin').extract('style-loader', 'css-loader!less-loader'),
styles: {
"mixins": true,
"core": true,
"icons": true,
"larger": true,
"path": true,
},
module: {
loaders: [
{
loader: 'babel-loader',
test: /\.jsx?$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src/js/'),
query: {
'plugins': [ 'transform-runtime' ],
'presets': [ 'es2015', 'stage-0', 'react' ].concat(additionalPlugins)
},
},
{
test: /\.(css|less$)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader'),
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff" },
{
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'url-loader?limit=8192',
},
{ test: /\.hbs$/, loader: "handlebars" },
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"}
],
},
},
];