forked from c3subtitles/L2S2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
109 lines (103 loc) · 2.67 KB
/
webpack.config.js
File metadata and controls
109 lines (103 loc) · 2.67 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
/* eslint camelcase: 0 */
'use strict';
const path = require('path');
const webpack = require('webpack');
const node_env = (process.env.NODE_ENV || 'development').trim();
const configPath = `configuration.${node_env}.js`;
const HtmlWebpackPlugin = require('html-webpack-plugin');
let plugins = [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
BLUEBIRD_LONG_STACK_TRACES: JSON.stringify(false),
NODE_ENV: JSON.stringify(node_env),
},
IS_PRODUCTION: JSON.stringify(node_env === 'production'),
CONFIGPATH: JSON.stringify(configPath),
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
minify: {},
}),
new HtmlWebpackPlugin({
filename: 'clean/index.html',
template: 'src/Clean/index.html',
minify: {},
}),
];
let jsLoader = 'babel!eslint';
if (node_env === 'production') {
plugins = plugins.concat([
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.UglifyJsPlugin(),
]);
jsLoader = 'babel';
}
const webpackConfig = {
eslint: {
configFile: '.eslintrc',
failOnWarning: false,
failOnError: true,
},
context: __dirname,
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
root: path.resolve('src'),
alias: {
bluebird: 'bluebird/js/release/bluebird.js',
eventemitter: 'eventemitter3',
},
},
entry: {
'Common': path.resolve('src/entry.js'),
'Clean': path.resolve('src/Clean/entry.js'),
},
output: {
path: path.resolve('www'),
filename: '[name]-[hash].js',
chunkFilename: '[id]-[chunkhash].js',
publicPath: '/',
},
module: {
loaders: [
{ test: /^((?!CSS\.js$).)*(\.jsx?)$/,
exclude: /(node_modules)/,
include: /src/,
loader: jsLoader,
},
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.CSS.js$/, exclude: /(node_modules)/, loader: 'inline-css!babel' },
{ test: /\.(jpg|png|gif|jpeg|ico)$/, loader: 'url?limit=10000' },
{ test: /\.woff2?(\?.*)?$/, loader: 'file' },
{ test: /\.(eot|ttf|otf|svg)(\?.*)?$/, loader: 'file' },
{ test: /\.json$/, loader: 'json' },
],
noParse: [
/primusClient\.js/,
],
},
plugins,
devServer: {
proxy: {
'/api/*': {
target: 'http://localhost:9500/',
changeOrigin: true,
xfwd: true,
ws: true,
secure: false,
},
'/primus/*': {
target: 'http://localhost:9500/',
changeOrigin: true,
xfwd: true,
ws: true,
secure: false,
},
},
},
};
if (node_env !== 'production') {
webpackConfig.devtool = 'cheap-module-source-map';
}
module.exports = webpackConfig;