-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
61 lines (58 loc) · 1.52 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
const webpack = require('webpack')
const { join, resolve } = require('path')
// Plugins
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const phaserPath = join(__dirname, '/node_modules/phaser/dist/phaser.js')
const srcPath = join(__dirname, 'src')
const distPath = resolve(__dirname, 'www')
module.exports = {
entry: join(srcPath, 'index.ts'),
output: {
filename: '[name].bundle.js',
path: distPath
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ },
{
test: /\.sass$/,
use: [
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
'sass-loader' // compiles Sass to CSS, using Node Sass by default
]
}
]
},
devServer: {
// serve assets from dist
contentBase: distPath,
// не показывает инфу а bundle
noInfo: true,
// overlay с ошибками
overlay: true
},
plugins: [
new CleanWebpackPlugin([distPath]),
new HtmlWebpackPlugin({
title: 'My page',
template: join(srcPath, 'index.html')
}),
new CopyWebpackPlugin([
// copy all assets to dist
{
from: join(srcPath, 'assets'),
to: join(distPath, 'assets')
},
])
],
resolve: {
extensions: ['.ts', '.js'],
alias: {
phaser: phaserPath,
'~': srcPath
}
}
}