-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
97 lines (91 loc) · 2.4 KB
/
webpack.config.js
File metadata and controls
97 lines (91 loc) · 2.4 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
if (typeof process.env.NODE_ENV === 'undefined') process.env.NODE_ENV = 'production';
console.log(process.env.NODE_ENV);
let path = require('path');
let webpack = require('webpack');
let config = {
context: path.join(__dirname, "/src"),
entry: [
'babel-polyfill',
'index.js'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
// publicPath: '/dist/',
// pathinfo: true
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
],
resolve: {
extensions: [/*'', */'.js', '.jsx'],
modules: [path.resolve(__dirname, 'src'), 'node_modules']
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{loader: 'babel-loader'}]
},
{
test: /\.css$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader', options: {url: true}},
]
},
{
test: /\.less$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader', options: {url: true}},
{loader: 'less-loader', options: {url: true, paths: [path.resolve(__dirname, 'src/ui/')]}},
]
},
{
test: /\.svg$/,
use: [{loader: 'svg-inline-loader'}]
},
{
test: /\.(svg|png|swf|jpg|otf|eot|ttf|woff|woff2)(\?.*)?$/,
exclude: path.resolve(__dirname, 'src/components/elements/icon'),
use: [
{loader: 'url-loader', options: {limit: 100000, name: 'assets/[hash].[ext]'}}
]
}
]
}
};
if (process.env.NODE_ENV === 'production') {
config.devtool = "nosources-source-map";
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
} else {
// config.entry.push('webpack-dev-server/client?http://localhost:8020');
// config.entry.push('webpack/hot/only-dev-server');
config.devtool = "#cheap-module-inline-source-map";
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.devServer = {
//compress: false,
contentBase: path.join(__dirname, "dist"),
port: 8010,
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
stats: {
colors: true
},
// proxy: {
// '/api/**': {
// target: 'http://slon.ozgg.ru',
// secure: false,
// changeOrigin: true
// },
// }
};
}
module.exports = config;