mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore: webpack: migrate to ESM
This commit is contained in:
parent
e178321be9
commit
8de9bd0847
8 changed files with 30 additions and 52 deletions
|
|
@ -1,9 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const {env} = require('node:process');
|
||||
|
||||
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
import {env} from 'node:process';
|
||||
import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||
|
||||
const isDev = env.NODE_ENV === 'development';
|
||||
|
||||
|
|
@ -29,7 +26,7 @@ const rules = [{
|
|||
type: 'asset/inline',
|
||||
}];
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
plugins,
|
||||
module: {
|
||||
rules,
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const {env} = require('node:process');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
import {env} from 'node:process';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
|
||||
const isDev = env.NODE_ENV === 'development';
|
||||
|
||||
const plugins = [
|
||||
export const plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
template: 'html/index.html',
|
||||
|
|
@ -13,10 +11,6 @@ const plugins = [
|
|||
}),
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
function getMinifyHtmlOptions() {
|
||||
return {
|
||||
removeComments: true,
|
||||
|
|
@ -1,18 +1,12 @@
|
|||
'use strict';
|
||||
import {resolve, sep} from 'node:path';
|
||||
import {env} from 'node:process';
|
||||
import webpack from 'webpack';
|
||||
import WebpackBar from 'webpackbar';
|
||||
|
||||
const {
|
||||
resolve,
|
||||
sep,
|
||||
join,
|
||||
} = require('node:path');
|
||||
|
||||
const {env} = require('node:process');
|
||||
const {
|
||||
EnvironmentPlugin,
|
||||
NormalModuleReplacementPlugin,
|
||||
} = require('webpack');
|
||||
|
||||
const WebpackBar = require('webpackbar');
|
||||
} = webpack;
|
||||
|
||||
const modules = './modules';
|
||||
const dirModules = './client/modules';
|
||||
|
|
@ -23,7 +17,7 @@ const dir = './client';
|
|||
const {NODE_ENV} = env;
|
||||
const isDev = NODE_ENV === 'development';
|
||||
|
||||
const rootDir = join(__dirname, '..');
|
||||
const rootDir = new URL('..', import.meta.url).pathname;
|
||||
const dist = resolve(rootDir, 'dist');
|
||||
const distDev = resolve(rootDir, 'dist-dev');
|
||||
const devtool = isDev ? 'eval' : 'source-map';
|
||||
|
|
@ -92,7 +86,7 @@ const splitChunks = {
|
|||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
resolve: {
|
||||
symlinks: false,
|
||||
alias: {
|
||||
|
|
@ -100,8 +94,8 @@ module.exports = {
|
|||
'node:path': 'path',
|
||||
},
|
||||
fallback: {
|
||||
path: require.resolve('path-browserify'),
|
||||
process: require.resolve('process/browser'),
|
||||
path: import.meta.resolve('path-browserify'),
|
||||
process: import.meta.resolve('process/browser'),
|
||||
},
|
||||
},
|
||||
devtool,
|
||||
Loading…
Add table
Add a link
Reference in a new issue