-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack.demo.config.ts
58 lines (55 loc) · 1.47 KB
/
webpack.demo.config.ts
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
import webpack from 'webpack'
import path from 'path'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import { CleanWebpackPlugin } from 'clean-webpack-plugin'
import CopyPlugin from 'copy-webpack-plugin'
import type { Configuration as DevServerConfiguration } from "webpack-dev-server";
const devServer: DevServerConfiguration = {
port: 9000,
};
const exampleConfig: webpack.Configuration = {
mode: 'development',
entry: path.resolve(__dirname, 'example/src/index.js'),
output: {
path: path.resolve(__dirname, 'dist-example/'),
filename: 'index.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/react']
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
},
],
},
]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'example/public/index.html')
}),
new CopyPlugin({
patterns: [
{ from: 'example/public/favicon.ico', to: 'favicon.ico' },
{ from: 'example/public/favicon.png', to: 'favicon.png' },
{ from: 'example/public/manifest.json', to: 'manifest.json' },
]})
],
devServer,
}
export default exampleConfig