forked from blinkenrocket/webedit-react
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
102 lines (94 loc) · 2.66 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
95
96
97
98
99
100
101
102
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var process = require('process');
var webpack = require('webpack');
var fs = require('fs');
var node_env = process.env.NODE_ENV || 'development';
var configPath = `config.${node_env}.js`;
var config = {};
if (fs.existsSync(`config.${node_env}.js`)) {
config = require(`./config.${node_env}.js`);
}
var plugins = [
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({
template: 'html-loader!./src/index.html',
title: 'Webedit',
minify: {},
inject: 'body',
hash: true,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(node_env)
},
__DEV__: JSON.stringify(node_env !== 'production'),
__PROD__: JSON.stringify(node_env === 'production'),
CONFIG: JSON.stringify(config),
BASE_URL: JSON.stringify(`/${process.env.BASE_URL || ''}`),
}),
];
if (node_env === 'production') {
plugins.push(
new webpack.optimize.UglifyJsPlugin()
);
}
const esLintOptions = {
configFile: './src/.eslintrc',
failOnWarning: false,
failOnError: true
};
module.exports = {
devtool: node_env === 'production' ? undefined : 'cheap-module-source-map',
context: __dirname,
resolve: {
modules: [path.join(__dirname, 'src'), "node_modules"],
extensions: ['.jsx', '.js', '.json'],
alias: {
'bluebird': 'bluebird/js/browser/bluebird.min.js',
'bonsai': 'bonsai/src/bootstrapper/_build/common.js',
},
},
entry: [
'./src/index.js'
],
output: {
path: path.resolve('public'),
filename: 'app-[hash].js',
publicPath: ''
},
module: {
rules: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /.*\.CSS\.js$/,
use: [
{ loader: 'inline-css-loader' },
{ loader: 'babel-loader' },
{
loader: 'eslint-loader',
options: esLintOptions,
}
],
exclude: /(node_modules)/,
include: /src/,
},
{ test: /^((?!CSS\.js$).)*\.jsx?$/,
exclude: /(node_modules)/,
include: /src/,
use: [{
loader: 'babel-loader',
}, {
loader: 'eslint-loader',
options: esLintOptions,
}],
},
{ test: /\.(jpg|png|gif)$/, loader: 'file!image' },
{ test: /\.svg/, loader: 'url-loader', include: /node_modules\/font-awesome/ },
{ test: /\.woff2?(\?v=.*)?$/, loader: 'url-loader?limit=10000&minetype=application/font-woff' },
{ test: /\.(eot|ttf|otf)(\?v=.*)?$/, loader: 'url-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.svg$/, loader: 'svg-inline-loader' }
],
},
plugins,
};