forked from adobe/react-starter-kit-aem-headless-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
60 lines (59 loc) · 1.88 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pkg = require('./package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack')
require('dotenv').config({ path: './.env' });
const alias = Object.keys(pkg.dependencies)
.reduce((obj, key) => ({...obj, [key]: path.resolve(__dirname, 'node_modules', key)}), {});
module.exports = {
entry: './src/index.tsx',
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
title: 'AEM Forms - Sample',
template: "public/index.html"
}),
new MiniCssExtractPlugin({
filename: 'dist/[name].css',
}),
new webpack.DefinePlugin({
process: {
browser: true,
env: {
USE_LOCAL_JSON: `'${process.env.USE_LOCAL_JSON}'`,
AEM_FORM_PATH: `'${process.env.AEM_FORM_PATH}'`,
AEM_USERNAME: `'${process.env.AEM_USERNAME}'`,
AEM_PASSWORD: `'${process.env.AEM_PASSWORD}'`,
AEM_URL: `'${process.env.AEM_URL}'`,
FORM_API: `'${process.env.FORM_API}'`
}
}
}),
],
resolve: {
alias: {
...alias
},
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
//sourceMapFilename: `clientlib-forms-react/resources/[name].map[ext]` // uncomment for debugging
}
};