-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
124 lines (123 loc) · 3.39 KB
/
webpack.common.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const webpack = require('webpack')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
entry: {
base: {
import: [
'./wine_cellar/assets/css/menu.css',
'./wine_cellar/assets/css/detail.css',
'./wine_cellar/assets/css/utility.css',
'./wine_cellar/assets/css/card.css',
'./wine_cellar/assets/css/forms.css',
'./wine_cellar/assets/css/styles.css',
'./wine_cellar/assets/css/page-layout.css',
'./wine_cellar/assets/css/homepage.css',
'./node_modules/tom-select/dist/css/tom-select.css',
'./node_modules/@fortawesome/fontawesome-free/css/fontawesome.css',
'./node_modules/@fortawesome/fontawesome-free/css/solid.css',
]
},
tom_select: {
import: [
'./wine_cellar/assets/js/init_tom_select.ts'
],
}
},
output: {
path: path.resolve('./wine_cellar/static/'),
publicPath: '/static/'
},
externals: {
django: 'django'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules\/.*/, // exclude most dependencies
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'].map(require.resolve),
plugins: ['@babel/plugin-transform-runtime', '@babel/plugin-transform-modules-commonjs']
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader',
options: {
url: {
filter: (url, resourcePath) => {
// only handle `/` urls, leave rest in code (pythong images to be left)
if (!url.startsWith('/')) {
return true
} else {
return false
}
}
}
}
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
require('autoprefixer')
]
}
}
},
]
},
{
test: /fonts\/.*\.(svg|woff2?|ttf|eot)(\?.*)?$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name][ext]'
}
},
{
test: /\.svg$|\.png$/,
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]'
}
}
]
},
resolve: {
fallback: { path: require.resolve('path-browserify') },
extensions: ['*', '.js', '.jsx', '.scss', '.css', '.ts', '.tsx'],
alias: {
},
// when using `npm link`, dependencies are resolved against the linked
// folder by default. This may result in dependencies being included twice.
// Setting `resolve.root` forces webpack to resolve all dependencies
// against the local directory.
modules: [path.resolve('./node_modules')]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css'
}),
new CopyWebpackPlugin({
patterns: [{
from: './wine_cellar/assets/images/**/*',
to: 'images/[name][ext]'
}]
})
]
}