From db7b02e69064c67d72291209318551734e53620a Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Fri, 10 May 2024 17:17:48 +0800 Subject: [PATCH 1/2] feat: moment.js --- rspack/moment-js/index.html | 12 ++++++++++++ rspack/moment-js/index.js | 2 ++ rspack/moment-js/package.json | 20 ++++++++++++++++++++ rspack/moment-js/rspack.config.js | 30 ++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 rspack/moment-js/index.html create mode 100644 rspack/moment-js/index.js create mode 100644 rspack/moment-js/package.json create mode 100644 rspack/moment-js/rspack.config.js diff --git a/rspack/moment-js/index.html b/rspack/moment-js/index.html new file mode 100644 index 00000000..ae516aa1 --- /dev/null +++ b/rspack/moment-js/index.html @@ -0,0 +1,12 @@ + + + + + + + + +
+ + + diff --git a/rspack/moment-js/index.js b/rspack/moment-js/index.js new file mode 100644 index 00000000..c11997a0 --- /dev/null +++ b/rspack/moment-js/index.js @@ -0,0 +1,2 @@ +const moment = require('moment'); +moment().format(); diff --git a/rspack/moment-js/package.json b/rspack/moment-js/package.json new file mode 100644 index 00000000..a5a56e9a --- /dev/null +++ b/rspack/moment-js/package.json @@ -0,0 +1,20 @@ +{ + "name": "example-monaco-editor-js", + "version": "1.0.0", + "private": true, + "main": "index.js", + "scripts": { + "dev": "rspack serve", + "build:local": "rspack build" + }, + "license": "MIT", + "dependencies": { + "@rspack/cli": "latest", + "moment": "^2.30.1", + "monaco-editor": "^0.39.0" + }, + "devDependencies": { + "@rspack/core": "latest", + "moment-locales-webpack-plugin": "^1.2.0" + } +} \ No newline at end of file diff --git a/rspack/moment-js/rspack.config.js b/rspack/moment-js/rspack.config.js new file mode 100644 index 00000000..129b6ccb --- /dev/null +++ b/rspack/moment-js/rspack.config.js @@ -0,0 +1,30 @@ +const rspack = require("@rspack/core"); +const path = require("path"); +const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); + +module.exports = { + entry: { + app: "./index.js" + }, + output: { + globalObject: "self", + filename: "[name].bundle.js", + path: path.resolve(__dirname, "dist") + }, + module: { + rules: [ + { + test: /\.ttf$/, + type: "asset/resource" + } + ] + }, + plugins: [ + new rspack.HtmlRspackPlugin({ + template: "./index.html" + }), + new MomentLocalesPlugin({ + localesToKeep: ['es-us', 'ru'], + }), + ] +}; From dcbf442341ec15c331b4b7509476089636bc7e52 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Fri, 17 May 2024 16:51:10 +0800 Subject: [PATCH 2/2] fix: package.json --- rspack/moment-js/package.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rspack/moment-js/package.json b/rspack/moment-js/package.json index a5a56e9a..2faf13f4 100644 --- a/rspack/moment-js/package.json +++ b/rspack/moment-js/package.json @@ -5,16 +5,15 @@ "main": "index.js", "scripts": { "dev": "rspack serve", - "build:local": "rspack build" + "build": "rspack build" }, "license": "MIT", "dependencies": { - "@rspack/cli": "latest", - "moment": "^2.30.1", - "monaco-editor": "^0.39.0" + "moment": "^2.30.1" }, "devDependencies": { + "@rspack/cli": "latest", "@rspack/core": "latest", "moment-locales-webpack-plugin": "^1.2.0" } -} \ No newline at end of file +}