-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
118 lines (114 loc) · 3.57 KB
/
webpack.config.js
File metadata and controls
118 lines (114 loc) · 3.57 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
109
110
111
112
113
114
115
116
117
118
var webpack = require('webpack');
//var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
//var CopyWebpackPlugin = require('copy-webpack-plugin');
//var proxy = require('http-proxy-middleware');
var path = require('path');
var serverConfig = require('./server.config.json');
var name = path.basename(__dirname);
var outputFilename = name + '.js';
var devServerHost = serverConfig.devServerHost || "http://localhost";
var devServerPort = parseInt(serverConfig.devServerPort, 10) || 8080;
// default configuration
var config = {
entry: {
js: [
//"webpack-dev-server/client?http://localhost:" + devServerPort,
//"webpack/hot/only-dev-server",
"./src/component.js" // input file
]
},
output: {
path: path.resolve(serverConfig.buildFolder),
filename: outputFilename, // output file
// publicPath: 'http://localhost:8080/sense'
},
externals: {
//"react": "React",
//"react-dom": "ReactDOM",
"js/qlik": "Qlik"
},
plugins: [
//new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['', '.js', '.jsx'],
modulesDirectories: ['node_modules']
},
module: {
noParse: ["react", "react.min", "react-dom", "react-dom.min", "js/qlik"],
loaders: [
{
test: /\.jsx?$/,
//exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
loaders: ['babel']
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
}
]
}
};
if(process.env.NODE_ENV !== 'production') {
console.log('DEVELOPMENT configuration');
config.devtool = 'inline-source-map'; //'#eval-source-map';
//config.devtool = 'source-map';
config.debug = true;
config.output.path = path.resolve(serverConfig.deployFolder);
// config.entry.js.unshift("webpack/hot/dev-server");
config.entry.js.unshift("webpack-dev-server/client?http://localhost:" + devServerPort);
// + "/", "webpack/hot/dev-server");
//config.plugins.push(new webpack.HotModuleReplacementPlugin());
/*
config.plugins.push(new BrowserSyncPlugin(
// BrowserSync options
{
// browse to http://localhost:devServerPort/ during development
host: 'localhost',
port: devServerPort+1,
// proxy the Webpack Dev Server endpoint
// (which should be serving on http://localhost:3100/)
// through BrowserSync
proxy: {
// middleware: [proxy({
// target: serverConfig.url,
// ws: true
// })],
target: serverConfig.url,
// //devServerHost + ':' + devServerPort,
ws: true
}
},
// plugin options
{
// prevent BrowserSync from reloading the page
// and let Webpack Dev Server take care of this
reload: true
}
));
*/
} else {
console.log('PRODUCTION configuration');
config.plugins.push(new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify('production')}
}));
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
// Compression specific options
compress: {
warnings: false,
// Drop `console` statements
drop_console: true
},
output: {
comments: false,
},
}));
config.plugins.push(new webpack.optimize.DedupePlugin());
config.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
// config.plugins.push(new CopyWebpackPlugin([{
// from: 'build',
// to: path.resolve(serverConfig.deployFolder)
// }]));
}
module.exports = config;