forked from waves-exchange/neutrino-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.js
executable file
·111 lines (109 loc) · 3.56 KB
/
webpack.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
const Dotenv = require('dotenv-webpack');
const path = require('path');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const srcPath = path.join(__dirname, 'src');
require('yii-steroids/webpack')
.config({
port: 8082,
baseUrl: '',
staticPath: '',
outputPath: __dirname + '/dist',
sourcePath: srcPath,
useHash: true,
devServer: {
hot: false,
inline: false,
liveReload: false,
proxy: [
{
'**': null,
},
{
context: ['/api', '/static'],
target: 'http://localhost:5000',
},
]
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'js/[hash].js',
chunkFilename: 'js/[id].[hash].chunk.js'
},
optimization: {
runtimeChunk: 'single',
minimizer: [
new OptimizeCSSAssetsPlugin({
cssProcessorPluginOptions: {
preset: [ 'default', { discardComments: { removeAll: true } } ],
}
}),
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true
})
],
splitChunks: {
chunks: 'async',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
automaticNameMaxLength: 30,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
webpack: {
module: {
rules: {
favicon: {
test: /\.ico$/,
use: {
file: {
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
},
},
},
},
typescript: {
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
configFile: 'tsconfig-node.json'
}
},
no_autoreload: { // Disable webpack-dev-server's auto-reload feature in the browser.
test: path.resolve(__dirname, 'node_modules/webpack-dev-server/client'),
loader: 'null-loader'
}
},
},
plugins: [
new Dotenv({
path: './.env',
}),
],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.ts', '.tsx', '.js'],
modules: [srcPath, 'node_modules'],
}
},
})
.base('./src/index.js');