-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.config.js
66 lines (56 loc) · 1.67 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
/* eslint-disable node/no-extraneous-require, node/no-unpublished-require */
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { ProvidePlugin } = require('webpack')
module.exports = {
// Where to fine the source code
context: path.join(__dirname, '/src'),
// No source map for production build
devtool: 'source-map',
entry: path.join(__dirname, '/src/app.ts'),
optimization: {
// We no not want to minimize our code.
minimize: false,
},
output: {
// The destination file name concatenated with hash (generated whenever you change your code).
// The hash is really useful to let the browser knows when it should get a new bundle
// or use the one in cache
filename: 'app.js',
// The destination folder where to put the output bundle
path: path.join(__dirname, '/dist'),
// Wherever resource (css, js, img) you call <script src="..."></script>,
// or css, or img use this path as the root
publicPath: '/',
// At some point you'll have to debug your code, that's why I'm giving you
// for free a source map file to make your life easier
sourceMapFilename: 'main.map',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
devServer: {
contentBase: path.join(__dirname, '/public'),
// match the output path
publicPath: '/',
// match the output `publicPath`
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: path.join(__dirname, '/public'), to: path.join(__dirname, '/dist') }],
}),
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
],
}