-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
121 lines (120 loc) · 3.13 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
/*
./webpack.config.js
*/
const path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
webpack = require('webpack'),
MiniCssExtractPlugin = require('mini-css-extract-plugin'),
ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
entry: ['./client/index.js'],
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index_bundle.js',
publicPath: '/static/',
},
module: {
rules: [
{
test: /.*(deep-equals|shallow-equals|pikaday).*\.js$/,
loader: 'babel-loader',
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
},
],
},
{
test: /\.less$/,
exclude: /node_modules/,
use: [MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
},
{
loader: 'less-loader',
},
],
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
exclude: /static/,
},
{
test: /\.(json|png|ico|xml|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
],
},
resolve: {
extensions: ['.js', '.jsx', 'less'],
alias: {
COMPONENTS: path.resolve('./client/components'),
RAW: path.resolve('./client/components/raw'),
DIALOG: path.resolve('./client/components/dialog'),
CONNECTED: path.resolve('./client/components/connected'),
PAGES: path.resolve('./client/components/views'),
UTILS: path.resolve('./client/utils'),
STORE: path.resolve('./client/store'),
T_RES: path.resolve('./test/client/resources'),
T_UI: path.resolve('./test/client/uitests'),
T_UNIT: path.resolve('./test/client/unittests'),
SW: path.resolve('./node_modules/serviceworker-webpack-plugin/lib'),
},
},
plugins: [
new webpack.IgnorePlugin(/.*moment.*/),
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
new ServiceWorkerWebpackPlugin({
entry: './client/sw.js',
filename: 'sw.js',
}),
new HtmlWebpackPlugin({
template: './client/index.html',
filename: 'index.html',
inject: 'body',
minify: {
removeComments: true,
collapseWhitespace: true,
},
}),
new CopyPlugin({
patterns: [
{ from: "**/*", to: "./", context: "./client/static/" }
],
}),
],
}