Skip to content

Commit 3c64bcc

Browse files
committed
refactor webpack config to ES module
1 parent 01d2db1 commit 3c64bcc

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"url": "https://github.com/zendive/jsdiff/issues"
2828
},
2929
"homepage": "https://github.com/zendive/jsdiff#readme",
30+
"type": "module",
3031
"devDependencies": {
3132
"@vue/compiler-sfc": "^3.2.31",
3233
"clean-webpack-plugin": "~4.0.0",

webpack.config.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
const path = require('path');
2-
const webpack = require('webpack');
3-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4-
const { VueLoaderPlugin } = require('vue-loader');
5-
const BundleAnalyzerPlugin =
6-
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
7-
8-
module.exports = function (env, op) {
1+
import path from 'path';
2+
import webpack from 'webpack';
3+
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
4+
import { VueLoaderPlugin } from 'vue-loader';
5+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
6+
import { fileURLToPath } from 'url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
11+
export default function (env, op) {
12+
console.log('⌥', env, op.mode);
913
const isProd = op.mode === 'production';
1014

1115
return {
@@ -22,13 +26,13 @@ module.exports = function (env, op) {
2226

2327
resolve: {
2428
modules: [path.resolve(__dirname, 'src/js'), 'node_modules'],
25-
2629
alias: {},
2730
},
2831

2932
plugins: [
3033
new CleanWebpackPlugin(),
3134
new VueLoaderPlugin(),
35+
// http://127.0.0.1:8888
3236
new BundleAnalyzerPlugin({
3337
openAnalyzer: false,
3438
logLevel: 'silent',
@@ -58,4 +62,4 @@ module.exports = function (env, op) {
5862

5963
devtool: isProd ? false : 'source-map',
6064
};
61-
};
65+
}

0 commit comments

Comments
 (0)