-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
49 lines (48 loc) · 1.45 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
mode: "development",
entry: './src/scripts/index.ts',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
devtool: "source-map",
devServer: {
contentBase: "./dist",
open: true,
proxy: [{
path: "/api",
target: "http://localhost:3000",
changeOrigin: true,
}],
},
resolve: {
extensions: [".ts", ".js"] // If multiple files share the same name but have different extensions, webpack will resolve the one with the extension listed first in the array and skip the rest.
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|mp3)$/i,
loader: 'file-loader',
options: {
name: "[name].[ext]",
publicPath: 'assets', // Reference location (doesn't work when only using 'outputPath')
outputPath: 'assets', // Export location
},
},
{ test: /\.html$/i, loader: 'html-loader', },
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ test: /\.js$/, loader: "source-map-loader" },
{
test: /\.s[ac]ss$/i,
use: [
'style-loader', // Creates `style` nodes from JS strings
'css-loader', // Translates CSS into CommonJS
'sass-loader', // Compiles Sass to CSS
],
},
]
},
plugins: [new HtmlWebpackPlugin({ template: "./public/index.html" })]
};