-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path_webpack.config.js
135 lines (115 loc) · 3.02 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* Bundle config
*/
let webpack = require('webpack');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
let path = require('path');
require('dotenv').config();
/**
* Configure plugins
* @type {Array}
*/
let plugins = [
/** Block build if errors found */
new webpack.NoEmitOnErrorsPlugin(),
/** Extract CSS bundle */
new ExtractTextPlugin('bundle.css'),
];
module.exports = {
entry: './public/javascripts/app.js',
output: {
filename: './bundle.js',
library: ['codex', 'notes'],
path: path.resolve( __dirname, 'public', 'build')
},
target: 'electron-renderer',
module: {
rules: [
{
test : /\.(png|jpg|svg)$/,
use : 'file-loader?name=[path][name].[ext]'
},
{
/**
* Use for all CSS files loaders below
* - extract-text-webpack-plugin
* - postcss-loader
*/
test: /\.css$/,
exclude: /node_modules/,
/** extract-text-webpack-plugin */
use: ExtractTextPlugin.extract([
{
loader: 'css-loader',
options: {
minimize: process.env.DEBUG !== 'true' ? 1 : 0,
importLoaders: 1
}
},
{
loader: 'postcss-loader'
}
])
},
{
/**
* Use for all JS files loaders below
* - babel-loader
* - eslint-loader
*/
test: /\.js$/,
exclude : /node_modules/,
use : [
/** Babel loader */
{
loader: 'babel-loader',
options: {
presets: [ 'env' ]
},
},
/** ES lint For webpack build */
{
loader: 'eslint-loader',
options: {
fix: true,
sourceType: 'module'
}
}
]
}
]
},
/**
* Add plugins
*/
plugins,
resolve: {
// options for resolving module requests
// (does not apply to resolving to loaders)
modules: [
'node_modules',
path.resolve(__dirname, 'public/')
],
// directories where to look for modules
extensions: ['.js', '.json', '.jsx', '.css'],
// extensions that are used
alias: {
// a list of module name aliases
// 'module': 'new-module',
// alias "module" -> "new-module" and "module/path/file" -> "new-module/path/file"
// 'only-module$': 'new-module',
// alias "only-module" -> "new-module", but not "module/path/file" -> "new-module/path/file"
// alias "module" -> "./app/third/module.js" and "module/file" results in error
// modules aliases are imported relative to the current context
},
/* alternative alias syntax (click to show) */
/* Advanced resolve configuration (click to show) */
},
devtool: 'source-map',
/** Пересборка при изменениях */
watch: true,
watchOptions: {
/** Таймаут перед пересборкой */
aggregateTimeout: 50
}
};