-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
55 lines (50 loc) · 1.43 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const yaml = require('yaml');
const fs = require('fs');
const args = process.argv.slice(2);
const isDev = args.some(a => a === '--dev');
const config = yaml.parse(fs.readFileSync('config.yml', 'utf8'));
const {outputFileName, htmlTitle} = config;
module.exports = {
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
mode: 'production',
plugins: [
new HtmlWebpackPlugin({
title: htmlTitle,
template: './src/template.html.ejs',
templateParameters: {
// inject parameters into template
title: htmlTitle,
exampleParameter: 'EXAMPLE_PARAMETER'
},
filename: outputFileName,
inlineSource: '.(js|css|ts)$'
}),
new HtmlWebpackInlineSourcePlugin()
],
optimization: {
minimize: !isDev // only minimise when not running in dev-mode
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' },
{
test: /\.scss$/,
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
]
}
]
}
};