forked from E-Health/fred
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.cjs
84 lines (81 loc) · 1.81 KB
/
webpack.config.cjs
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
const Dotenv = require('dotenv-webpack');
module.exports = (env) => {
// Default to env.development
if (!('build' in env)) {
env.development = true;
}
let config = {
devServer: {
static: {
directory: './public',
},
client: {
progress: true,
},
historyApiFallback: true,
proxy: {
// '/authoring': 'http://localhost:9000',
// '/structor': 'http://localhost:9001',
// '/iframe': 'http://localhost:9001', // also for structor
},
port: 8083,
allowedHosts: [
'localhost:8083',
'dev.sage.junipercds.com'
]
},
entry: {
bundle: './src/index.tsx',
},
output: {
filename: '[name].js',
},
mode: env.development ? 'development' : 'production',
plugins: [
new Dotenv({
systemvars: true, // load all the predefined 'process.env' variables which will trump anything local per dotenv specs. (from dotenv-webpack docs)
}), // Loads variables from file ".env" into `process.env` accessible in application code
],
target: 'web',
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/react', '@babel/env']
},
resolve: {
fullySpecified: false, // true-to-spec ES Modules should compile without error with default 'true'
},
},
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: false
}
}
],
exclude: /node_modules/,
},
{
test:[/\.css$/],
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".jsx", '...'], // '...' tells it to use the default extensions array
modules: ["node_modules"]
}
};
return config;
}