Skip to content

Commit

Permalink
feat: support webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Apr 17, 2022
1 parent c25b0bf commit 1ba0d7c
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 14 deletions.
43 changes: 43 additions & 0 deletions examples/webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "rollup-example",
"version": "0.1.0",
"keywords": [
"unplugin",
"vite",
"webpack",
"rollup",
"transform"
],
"homepage": "https://github.com/1247748612/unplugin-moment-to-dayjs#readme",
"bugs": {
"url": "https://github.com/1247748612/unplugin-moment-to-dayjs/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/1247748612/unplugin-moment-to-dayjs.git"
},
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist",
"*.d.ts"
],
"scripts": {
"build": "webpack",
"dev": "webpack --watch"
},
"dependencies": {
"dayjs": "^1.11.0",
"moment": "^2.29.2"
},
"devDependencies": {
"unplugin-moment-to-dayjs": "workspace:*",
"webpack": "5.72.0",
"webpack-cli": "4.9.2"
},
"peerDependencies": {
"dayjs": "^1.11.0"
}
}
7 changes: 7 additions & 0 deletions examples/webpack/src/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import moment from 'moment'

export default function hello() {
moment.locale('zh-cn')

moment('2019-01-01')
}
8 changes: 8 additions & 0 deletions examples/webpack/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import moment from 'moment'
export { default as hello2 } from './hello'

export default function hello() {
moment.locale('zh-cn')

moment('2019-01-01')
}
21 changes: 21 additions & 0 deletions examples/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Configuration } from 'webpack'
import momentToDayjs from 'unplugin-moment-to-dayjs/webpack'

export default {
mode: 'development',
entry: './src/index.js',
output: {
clean: true,
library: {
type: 'module',
},
filename: 'main.js',
},
experiments: {
outputModule: true,
},
externals: ['dayjs'],
plugins: [
momentToDayjs(),
],
} as Configuration
Loading

0 comments on commit 1ba0d7c

Please sign in to comment.