-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.ts
62 lines (56 loc) · 1.43 KB
/
webpack.config.prod.ts
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
import * as path from "path";
import * as webpack from "webpack";
import * as fs from "fs";
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const file = fs.readFileSync("./.env", "utf8");
const lines = file.split("\n");
const bucket_name =
// @ts-ignore
lines.find((val) => val.startsWith("AWS_STORAGE_BUCKET_NAME")).split("=")[1];
const static_location =
// @ts-ignore
lines.find((val) => val.startsWith("AWS_STATIC_LOCATION")).split("=")[1];
const config: webpack.Configuration = {
context: __dirname,
devtool: "inline-source-map",
entry: {
main: "./static/ts/src/Index",
bootstrapjs: "./static/js/index",
style: "./static/css/main.css",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "babel-loader",
exclude: /node_modules/,
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
},
{
test: /\.css$/,
loader: "style-loader!css-loader",
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: "url-loader?limit=100000",
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
publicPath: `https://${bucket_name}.s3.amazonaws.com/${static_location}/bundles/`,
path: path.resolve("./static/bundles/"),
filename: "[name].js",
},
optimization: {
minimize: true,
minimizer: [new UglifyJsPlugin()],
},
};
export default config;