-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
75 lines (71 loc) · 1.98 KB
/
webpack.config.js
File metadata and controls
75 lines (71 loc) · 1.98 KB
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
/*
A webpack configuration file designed
for webdevelopment with typescript and scss
by Ebbe Vang, evang.dk
*/
const path = require('path');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
module.exports = {
// which files should webpack watch and transpile
entry: ['./src/index.htm', './src/scss/styles.scss', './src/js/index.ts'],
module: {
// rules webpack should follow when watching...
rules: [
{
//TypeScipt files will be handles (transpiled) by the typescript-loader
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
//(s)css files wil be handled by the scss-loader and then send to the css-loader and fuinally saved as a bundle
test:/\.(s*)css$/,
use:[{loader :'file-loader', options: {name: 'bundle.css'}}, 'extract-loader', 'css-loader', 'sass-loader']
},
{
// html files will be copied to the dist folder
test: /.htm(l*)/,
use:
{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
},
{
//all fonts are vopied to the fonts folder
test: /.(ttf|otf|eot|otf|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/', // where the fonts will go
publicPath: './fonts/' // override the default path
}
}]
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js', '.scss' ]
},
output: {
publicPath: '/dist/',
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist/')
},
devtool: 'source-map',
plugins: [
new BrowserSyncPlugin({
// browse to http://localhost:3000/ during development,
// ./public directory is being served
host: 'localhost',
reload: true,
port: 3000,
files: ["*.htm", "*.html", "scss/*.*"],
index: 'index.htm',
server: { baseDir: ['dist'] }
})
]
};