-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.config.ts
105 lines (98 loc) · 2.32 KB
/
webpack.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import HtmlWebpackPlugin from 'html-webpack-plugin';
import * as path from 'path';
import * as VueLoaderPlugin from 'vue-loader';
import * as webpack from 'webpack';
import * as webpackDevServer from 'webpack-dev-server';
import * as packageJSON from './package.json';
interface WebpackConfig extends webpack.Configuration {
devServer?: webpackDevServer.Configuration;
}
const config: WebpackConfig = {
entry: './src/main.ts',
output: {
filename: `site.js`,
path: path.resolve(__dirname, 'docs'),
},
mode: 'production',
module: {
rules: [
{
test: /\.(png|jpg)$/,
loader: 'url-loader'
},
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [
'\\.vue$',
],
},
},
],
},
{
test: /\.(s*)css$/, // match any .scss or .css file,
include: [
path.resolve(__dirname, './src/'),
path.resolve(__dirname, './node_modules/bootstrap/'),
],
use: [
"vue-style-loader",
"css-loader",
"sass-loader"
]
},
],
},
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all'
}
},
resolve: {
alias: {
'@': path.join(__dirname, '/src/'),
'vue$': 'vue/dist/vue.min.js',
'vuex$': 'vuex/dist/vuex.min.js',
'css-vars-ponyfill$': 'css-vars-ponyfill/dist/css-vars-ponyfill.min.js',
},
extensions: [
'.json',
'.ts',
'.vue',
'.js',
],
},
plugins: [
new VueLoaderPlugin.VueLoaderPlugin(),
new webpack.ProgressPlugin(),
new webpack.DefinePlugin({
CORE_VERSION: JSON.stringify(packageJSON.dependencies['@iabtcf/core'])
}),
new HtmlWebpackPlugin({
title:'iabtcf: IAB TCF Code Library',
template: './src/index.html',
}),
],
};
const isDevServer = process.argv.find((v): boolean => v.includes('webpack-dev-server'));
if (isDevServer) {
config.mode = 'development';
config.devtool = 'eval-source-map';
config.devServer = {
hot: true,
open: 'Google Chrome',
overlay: true,
contentBase: ['docs'],
watchContentBase: true,
};
}
export default config;