forked from sebastienbarbier/seven23
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack-production.config.js
More file actions
101 lines (98 loc) · 2.93 KB
/
webpack-production.config.js
File metadata and controls
101 lines (98 loc) · 2.93 KB
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
require("dotenv").config();
const webpack = require("webpack");
const path = require("path");
const buildPath = path.resolve(__dirname, "build");
const nodeModulesPath = path.resolve(__dirname, "node_modules");
const TransferWebpackPlugin = require("transfer-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const SentryCliPlugin = require("@sentry/webpack-plugin");
const config = {
entry: [path.join(__dirname, "/src/app/app.js")],
// Render source-map file for final build
devtool: "source-map",
// output config
output: {
path: buildPath, // Path of output file
filename: "app.js", // Name of output file
},
plugins: [
new CleanWebpackPlugin(),
// Define production build to allow React to strip out unnecessary checks
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
SENTRY_DSN: JSON.stringify(process.env.SENTRY_DSN),
BUILD_DATE: JSON.stringify(new Date()),
TRAVIS_COMMIT: JSON.stringify(process.env.TRAVIS_COMMIT),
},
}),
// Allows error warnings but does not stop compiling.
new webpack.NoEmitOnErrorsPlugin(),
// Transfer Files
new TransferWebpackPlugin(
[{ from: "www/html" }, { from: "www/images", to: "images" }],
path.resolve(__dirname, "src")
),
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling 'old' SWs to hang around
clientsClaim: false,
skipWaiting: false,
include: [
/\.html$/,
/\.js$/,
/\.jpg$/,
/\.svg$/,
/\.png$/,
/\.json$/,
/\.xml$/,
],
}),
new SentryCliPlugin({
release: "seven23@1.0.0-build." + process.env.TRAVIS_COMMIT,
include: "build",
ignoreFile: ".sentrycliignore",
ignore: [
"node_modules",
"webpack-dev-server.config.js",
"webpack-production.config.js",
],
}),
],
module: {
rules: [
{
// React-hot loader and
test: /\.js$/, // All .js files
loader: "babel-loader",
options: {
presets: ["@babel/env", "@babel/react"],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime",
"@babel/transform-arrow-functions",
],
},
exclude: [nodeModulesPath],
},
{
test: /\.worker.js$/,
loader: "worker-loader",
options: {
inline: "fallback",
filename: "[name].[contenthash].worker.js",
},
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(jpe?g|png|gif|svg|eot|woff|ttf|svg|woff2)$/,
loader: "file-loader?name=[name].[ext]",
},
],
},
};
module.exports = config;