Skip to content

Commit 92bf4e7

Browse files
committed
Use ESM syntax for webpack.config.js
1 parent 394f247 commit 92bf4e7

4 files changed

Lines changed: 61 additions & 27 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ lint-backend: golangci-lint revive vet
316316
.PHONY: watch-frontend
317317
watch-frontend: node-check $(FOMANTIC_DEST) node_modules
318318
rm -rf $(WEBPACK_DEST_ENTRIES)
319-
NODE_ENV=development npx webpack --hide-modules --display-entrypoints=false --watch --progress
319+
NODE_ENV=development npx webpack -r @babel/register --hide-modules --display-entrypoints=false --watch --progress
320320

321321
.PHONY: watch-backend
322322
watch-backend: go-check
@@ -639,7 +639,7 @@ webpack: $(WEBPACK_DEST)
639639

640640
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
641641
rm -rf $(WEBPACK_DEST_ENTRIES)
642-
npx webpack --hide-modules --display-entrypoints=false
642+
npx webpack -r @babel/register --hide-modules --display-entrypoints=false
643643
@touch $(WEBPACK_DEST)
644644

645645
.PHONY: svg

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"wrap-ansi": "7.0.0"
5252
},
5353
"devDependencies": {
54+
"@babel/register": "7.10.5",
5455
"eslint": "7.6.0",
5556
"eslint-plugin-import": "2.22.0",
5657
"eslint-plugin-unicorn": "21.0.0",
@@ -63,5 +64,10 @@
6364
"defaults",
6465
"not ie > 0",
6566
"not ie_mob > 0"
66-
]
67+
],
68+
"babel": {
69+
"presets": [
70+
"@babel/preset-env"
71+
]
72+
}
6773
}

webpack.config.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
const fastGlob = require('fast-glob');
2-
const wrapAnsi = require('wrap-ansi');
3-
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
4-
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
5-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6-
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
7-
const PostCSSPresetEnv = () => require('postcss-preset-env')({
8-
features: {
9-
'system-ui-font-family': false,
10-
}
11-
});
12-
const TerserPlugin = require('terser-webpack-plugin');
13-
const VueLoaderPlugin = require('vue-loader/lib/plugin');
14-
const {statSync} = require('fs');
15-
const {resolve, parse} = require('path');
16-
const {LicenseWebpackPlugin} = require('license-webpack-plugin');
17-
const {SourceMapDevToolPlugin} = require('webpack');
1+
import fastGlob from 'fast-glob';
2+
import wrapAnsi from 'wrap-ansi';
3+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
4+
import FixStyleOnlyEntriesPlugin from 'webpack-fix-style-only-entries';
5+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
6+
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
7+
import PostCSSPresetEnv from 'postcss-preset-env';
8+
import TerserPlugin from 'terser-webpack-plugin';
9+
import VueLoaderPlugin from 'vue-loader/lib/plugin';
10+
import {statSync} from 'fs';
11+
import {resolve, parse} from 'path';
12+
import {LicenseWebpackPlugin} from 'license-webpack-plugin';
13+
import {SourceMapDevToolPlugin} from 'webpack';
1814

1915
const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true});
2016

@@ -41,7 +37,15 @@ const filterCssImport = (url, ...args) => {
4137
return true;
4238
};
4339

44-
module.exports = {
40+
const postCSSPlugins = () => [
41+
PostCSSPresetEnv({
42+
features: {
43+
'system-ui-font-family': false,
44+
},
45+
}),
46+
];
47+
48+
export default {
4549
mode: isProduction ? 'production' : 'development',
4650
entry: {
4751
index: [
@@ -179,9 +183,7 @@ module.exports = {
179183
{
180184
loader: 'postcss-loader',
181185
options: {
182-
plugins: () => [
183-
PostCSSPresetEnv(),
184-
],
186+
plugins: postCSSPlugins,
185187
sourceMap: true,
186188
},
187189
},
@@ -205,9 +207,7 @@ module.exports = {
205207
{
206208
loader: 'postcss-loader',
207209
options: {
208-
plugins: () => [
209-
PostCSSPresetEnv(),
210-
],
210+
plugins: postCSSPlugins,
211211
sourceMap: true,
212212
},
213213
},

0 commit comments

Comments
 (0)