generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
103 lines (102 loc) · 2.71 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
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackDeployPlugin = require("html-webpack-deploy-plugin");
const ReplaceInFileWebpackPlugin = require("replace-in-file-webpack-plugin");
module.exports = {
mode: 'development',
entry: './amt/site/static/ts/amt.ts',
output: {
filename: 'amt.js',
path: path.resolve(__dirname, 'amt/site/static/dist'),
publicPath: '/static/dist/',
library: 'amt',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/i,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: {
outputStyle: "compressed",
},
},
},
],
},
]
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new HtmlWebpackPlugin({
template: 'amt/site/templates/layouts/base.html.j2.webpack',
filename: path.resolve(__dirname, 'amt/site/templates/layouts/base.html.j2'),
inject: false
}),
new HtmlWebpackDeployPlugin({
usePackagesPath: false,
getPackagePath: (packageName, packageVersion, packagePath) => path.join(packageName, packagePath),
packages: {
'@nl-rvo/assets': {
copy: [
{ from: 'fonts', to: 'fonts/'},
{ from: 'icons', to: 'icons/'},
{ from: 'images', to: 'images/'}
],
links: [
'fonts/index.css',
'icons/index.css',
'images/index.css',
]
},
'@nl-rvo/design-tokens': {
copy: [
{ from: 'dist/index.css', to: 'index.css' },
{ from: 'dist/index.js', to: 'index.mjs' },
],
links: [
'index.css',
],
scripts: [
'index.mjs',
]
},
'@nl-rvo/component-library-css': {
copy: [
{ from: 'dist/index.css', to: 'index.css' },
],
links: [
'index.css',
]
},
}
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
// to make CSS variables work, we replace the url with the full path
new ReplaceInFileWebpackPlugin([{
dir: 'amt/site/static/dist/@nl-rvo/assets/icons/',
files: ['index.css'],
rules: [{
search: /url\("/ig,
replace: 'url("/static/dist/@nl-rvo/assets/icons/'
}]
}])
]
};