forked from SuperSimpleDev/javascript-amazon-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.mjs
68 lines (62 loc) · 2.02 KB
/
webpack.config.mjs
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
import path from 'path';
import { glob } from 'glob';
export default {
// Entry points for production code and a separate entry for Jasmine tests
entry: {
amazon: './scripts/amazon.js',
checkout: './scripts/checkout.js',
orders: './scripts/orders.js',
// orderSummary: './scripts/checkout/orderSummary.js',
// Separate entry point for Jasmine test files
jasmineTests: glob
// .sync(['./tests/spec/**/*.js', './tests/src/**/*.js'])
.sync('./tests/spec/**/*.js')
.map((file) => `./${file.replace(/\\/g, '/')}`), // Glob to match all test files in the 'spec' folder
},
output: {
filename: '[name].bundle.js', // Separate bundles for production code and test code
path: path.resolve('dist'),
},
mode: 'development', // Change to 'production' for optimized builds
module: {
rules: [
{
test: /\.js$/, // Apply Babel loader to JavaScript files
exclude: /node_modules/, // Exclude third-party modules from Babel processing
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
edge: '129', // Target the latest version of Microsoft Edge
},
useBuiltIns: 'usage', // Include polyfills based on usage in your code
corejs: 3, // Use CoreJS version 3 for polyfills
},
],
],
},
},
},
{
test: /\.css$/i, // Apply this rule to CSS files
use: ['style-loader', 'css-loader'], // Process and inject CSS
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
type: 'asset',
},
],
},
resolve: {
fallback: {
fs: false, // Disable 'fs' module as it's not needed in the browser
path: false, // Disable 'path' module as well
},
},
// Optional: Enable source maps for easier debugging in the browser
// devtool: 'source-map',
};