-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
79 lines (70 loc) · 1.82 KB
/
webpack.config.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackDotenv = require('dotenv-webpack');
const SveltePreprocess = require("svelte-preprocess");
module.exports = {
mode: 'development',
entry: ['./src/main.ts'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/',
},
devtool: 'eval-cheap-module-source-map',
module: {
rules: [
//Allows use of modern javascript
{
test: /\.(js|ts)$/,
exclude: /node_modules/, //don't test node_modules folder
use: {
loader: 'babel-loader',
},
},
//Allows use of svelte
{
test: /\.svelte$/,
use: {
loader: 'svelte-loader',
options: {
compilerOptions: {
dev: true
},
hotReload: true,
preprocess: SveltePreprocess({})
}
},
},
//Allows use of CSS
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
//Allows use of images
{
test: /\.(jpg|jpeg|png|svg)$/,
type: 'asset/resource'
},
],
},
//this is what enables users to leave off the extension when importing
resolve: {
extensions: ['.mjs', '.js', '.svelte', '.ts'],
},
plugins: [
//Allows to create an index.html in our build folder
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
}),
//take our environment variable in .env file
//And it does a text replace in the resulting bundle for any instances of process.env.
new WebpackDotenv(),
],
////Config for webpack-dev-server module
devServer: {
port: 8088,
historyApiFallback: true,
contentBase: path.resolve(__dirname, 'dist'),
hot: true
},
};