forked from wikimedia-pl/wikiwakacje-2017-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
118 lines (113 loc) · 2.56 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
const path = require("path");
// const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
// var ngAnnotatePlugin = require("ng-annotate-webpack-plugin");
// eslint-disable-next-line import/no-extraneous-dependencies
const TerserPlugin = require("terser-webpack-plugin");
const packageJson = require("./package.json");
const config = {
mode: 'development',
context: path.join(__dirname, "src"),
entry: ["./index.js"],
output: {
path: path.join(__dirname, "app", "assets"),
publicPath: "auto",
filename: `bundle.js?v=${packageJson.version}`
},
plugins: [
new HtmlWebpackPlugin({
template: "index.html.ejs",
minify: false,
filename: path.join("..", "index.html")
}),
],
module: {
rules: [
{
test: /\.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: "defaults" }]
]
}
}
},
// {
// test: /\.jsx?$/,
// exclude: /node_modules/,
// loader: "ng-annotate"
// },
{
test: /\.html?$/,
loader: "raw-loader"
},
{
test: /\.css$/,
use: [
"style-loader",
"css-loader",
]
},
{
test: /\.scss$/,
use: [
"style-loader",
"css-loader",
"sass-loader",
]
},
// {
// test: /\.(woff|woff2|ttf|eot)$/,
// loader: 'url-loader',
// options: {
// name: '[name].[ext]',
// outputPath: 'fonts/',
// }
// },
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'images/',
}
},
]
}
};
/**
* Production mode re-configuration.
*/
function production() {
config.output = {
path: path.join(__dirname, "app-prod", "assets"),
publicPath: "auto",
filename: `bundle.[name].js?v=${packageJson.version}`
};
config.optimization = {
minimize: true,
splitChunks: {
chunks: 'all',
},
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: false, // uglify doesn't work with this project
compress: true, // compress = less whitespace
output: {
beautify: true // keep somewhat readable
}
},
}),
],
};
}
module.exports = (env) => {
if (env.prod) {
production();
}
return config;
}