From 8d930590772b4a7657ef0a5148b09aee0eed1331 Mon Sep 17 00:00:00 2001 From: seoyeoneel02 Date: Fri, 16 Aug 2024 18:06:09 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20webpack,=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=ED=99=95=EC=9E=A5=EC=9E=90=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- webpack.config.cjs | 33 --------------------------------- webpack.config.js | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 35 deletions(-) delete mode 100644 webpack.config.cjs create mode 100644 webpack.config.js diff --git a/package.json b/package.json index 0b1a3de..5e023a6 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start:dev": "nodemon --exec babel-node index.js", - "start:dist": "webpack --mode production & node ./dist/main.js", - "start": "node ./dist/main.js", + "start:dist": "webpack --mode production & node ./dist/main.cjs", + "start": "node ./dist/main.cjs", "dev": "nodemon index.js", "build": "webpack", "lint": "eslint .", diff --git a/webpack.config.cjs b/webpack.config.cjs deleted file mode 100644 index 4f538d9..0000000 --- a/webpack.config.cjs +++ /dev/null @@ -1,33 +0,0 @@ -const nodeExternals = require("webpack-node-externals"); -const path = require("path"); - -module.exports = { - mode: "development", - context: __dirname + '/src', - entry: { - app: '../index.js', - }, - output: { - path: path.resolve(__dirname, "dist"), - filename: "main.js", - }, - module: { - rules: [ - { - test: /\.js$/, - use: { - loader: "babel-loader", - options: { - presets: ["@babel/preset-env"], - }, - }, - exclude: /node_modules/, - }, - ], - }, - target: "node", - externalsPresets: { - node: true, - }, - externals: [nodeExternals()], - }; \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..c17f24f --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,38 @@ +import nodeExternals from 'webpack-node-externals'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +export default { + mode: "development", + context: `${__dirname}/src`, + entry: { + app: '../index.js', + }, + output: { + path: path.resolve(__dirname, "dist"), + filename: "main.cjs", + }, + module: { + rules: [ + { + test: /\.js$/, + use: { + loader: "babel-loader", + options: { + presets: ["@babel/preset-env"], + }, + }, + exclude: /node_modules/, + }, + ], + }, + target: "node", + externalsPresets: { + node: true, + }, + externals: [nodeExternals()], +}; \ No newline at end of file