This repository was archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.common.js
90 lines (89 loc) · 2.55 KB
/
webpack.common.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
const path = require("path");
const glob = require("glob");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
module.exports = {
entry: "./src/app.js",
module: {
rules: [{
test: /(\.jsx|\.js)$/,
exclude: /(node_modules|bower_components)/,
// When using with transpiling loaders (like babel-loader), make sure they are in correct order (bottom to top).
// Otherwise files will be check after being processed by babel-loader
use: [{
loader: "babel-loader",
query: {
presets: ["@babel/preset-env", "@babel/react"],
plugins: ["@babel/plugin-proposal-object-rest-spread", ["babel-plugin-root-import", { "rootPathSuffix": "src" }]]
}
},
{
loader: "eslint-loader",
options: {
quiet: true
}
}
]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.scss$/,
use: ["style-loader",
"css-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
includePaths: glob.sync(
path.join(__dirname, "**/node_modules/@material")
).map((dir) => path.dirname(dir)),
},
}
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'images/[hash]-[name].[ext]'
}
}]
}
]
},
plugins: [
new CopyWebpackPlugin([{
from: "./translations/**/*"
}]),
new CopyWebpackPlugin([{
from: "./img/**/*"
}]),
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/,
failOnError: true //change to false when debugging to fix these circular dependencies
}),
new HtmlWebpackPlugin({
title: "Real Time Map",
template: "./index-template.ejs",
favicon: "./favicon.png"
}),
new webpack.NamedModulesPlugin()
],
resolve: {
alias: {
actions: path.resolve(__dirname, "src", "actions"),
components: path.resolve(__dirname, "src", "components"),
constants: path.resolve(__dirname, "src", "constants"),
global: path.resolve(__dirname, "src", "components", "global"),
services: path.resolve(__dirname, "src", "services"),
utils: path.resolve(__dirname, "src", "utils")
}
},
};