Skip to content

Commit 0fca0fc

Browse files
committed
build: update webpack config to bring in line with API changes
1 parent 98527ba commit 0fca0fc

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

webpack.config.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44
const sass = require('sass');
55
const ESLintPlugin = require('eslint-webpack-plugin');
66
const StylelintPlugin = require('stylelint-webpack-plugin');
7-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
87

98
const projectRoot = 'tbx';
109

@@ -26,6 +25,7 @@ const options = {
2625
path: path.resolve(`./${projectRoot}/static_compiled/`),
2726
// based on entry name, e.g. main.js
2827
filename: 'js/[name].js', // based on entry name, e.g. main.js
28+
clean: true,
2929
},
3030
plugins: [
3131
new CopyPlugin({
@@ -56,8 +56,6 @@ const options = {
5656
emitWarning: true,
5757
extensions: ['scss'],
5858
}),
59-
// Automatically remove all unused webpack assets on rebuild
60-
new CleanWebpackPlugin(),
6159
],
6260
module: {
6361
rules: [
@@ -103,38 +101,44 @@ const options = {
103101
sourceMap: true,
104102
implementation: sass,
105103
sassOptions: {
106-
outputStyle: 'compressed',
104+
style: 'compressed',
107105
},
108106
},
109107
},
110108
],
111109
},
112110
{
113-
// sync font files referenced by the css to the fonts directory
114-
// the publicPath matches the path from the compiled css to the font file
115-
// only looks in the fonts folder so pngs in the images folder won't get put in the fonts folder
111+
// Copies font files referenced by CSS/JS to the fonts
112+
// directory.
113+
// Only files located in the static_src/fonts directory can be
114+
// referenced in CSS/JS. Trying to reference a font outside of
115+
// this directory will result in a build error. Make sure to
116+
// store all fonts in this directory.
116117
test: /\.(woff|woff2)$/,
117-
include: /fonts/,
118+
include: path.resolve(`./${projectRoot}/static_src/fonts/`),
118119
type: 'asset/resource',
120+
generator: {
121+
filename: 'fonts/[name][ext]',
122+
},
119123
},
120124
{
121125
// Handles CSS background images in the cssBackgrounds folder
122-
// Those less than 1024 bytes are automatically encoded in the CSS - see `_test-background-images.scss`
123-
// the publicPath matches the path from the compiled css to the cssBackgrounds file
126+
// Files smaller than 1024 bytes are automatically encoded in
127+
// the CSS - see `_test-background-images.scss`. Otherwise, the
128+
// image is copied to the images/cssBackgrounds directory.
124129
test: /\.(svg|jpg|png)$/,
125130
include: path.resolve(
126131
`./${projectRoot}/static_src/images/cssBackgrounds/`,
127132
),
128-
use: {
129-
loader: 'url-loader',
130-
options: {
131-
fallback: 'file-loader',
132-
name: '[name].[ext]',
133-
outputPath: 'images/cssBackgrounds/',
134-
publicPath: '../images/cssBackgrounds/',
135-
limit: 1024,
133+
type: 'asset',
134+
parser: {
135+
dataUrlCondition: {
136+
maxSize: 1024,
136137
},
137138
},
139+
generator: {
140+
filename: 'images/cssBackgrounds/[name][ext]',
141+
},
138142
},
139143
],
140144
},
@@ -194,10 +198,12 @@ const webpackConfig = (environment, argv) => {
194198
// When set to 'auto' this option always allows localhost, host, and client.webSocketURL.hostname
195199
allowedHosts: 'auto',
196200
port: 3000,
197-
proxy: {
198-
context: () => true,
199-
target: 'http://localhost:8000',
200-
},
201+
proxy: [
202+
{
203+
context: () => true,
204+
target: 'http://localhost:8000',
205+
},
206+
],
201207
client: {
202208
// Shows a full-screen overlay in the browser when there are compiler errors.
203209
overlay: true,

0 commit comments

Comments
 (0)