webpack -> Rollup (again)

This commit is contained in:
Pig Fang 2020-08-27 16:36:48 +08:00
parent f2aa09ad7c
commit 752d649d0b
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
6 changed files with 542 additions and 2482 deletions

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"svelte.svelte-vscode"
]
}

9
.vscode/tasks.json vendored
View File

@ -2,14 +2,19 @@
"version": "2.0.0",
"tasks": [
{
"label": "Run webpack for plugin assets",
"label": "Build plugin assets",
"type": "process",
"command": "yarn",
"args": [
"dev",
"-o",
"-d",
"../blessing-skin-server/public/plugins"
],
"options": {
"env": {
"NODE_ENV": "development"
}
},
"isBackground": true,
"problemMatcher": []
}

View File

@ -8,26 +8,26 @@
"plugins/*"
],
"scripts": {
"dev": "webpack -d -w",
"build": "webpack -p"
"dev": "rollup -c -w",
"build": "rollup -c"
},
"devDependencies": {
"@gplane/tsconfig": "^1.1.0",
"@types/gulp": "^4.0.6",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^5.0.2",
"@types/node": "^14.0.13",
"@types/react": "^16.9.32",
"@types/react-dom": "^16.9.6",
"@types/webpack": "^4.41.17",
"css-loader": "^4.2.1",
"fast-glob": "^3.2.4",
"sass": "^1.26.10",
"sass-loader": "^9.0.3",
"style-loader": "^1.2.1",
"ts-loader": "^8.0.1",
"ts-node": "^8.10.2",
"typescript": "^4.0.2",
"webpack": "^5.0.0-beta.18",
"webpack-cli": "^4.0.0-beta.8"
"rollup": "^2.26.5",
"rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.24.1",
"svelte-check": "^1.0.26",
"svelte-preprocess": "^4.1.1",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
},
"prettier": {
"printWidth": 80,

55
rollup.config.js Normal file
View File

@ -0,0 +1,55 @@
// @ts-check
import glob from 'fast-glob'
import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import svelte from 'rollup-plugin-svelte'
import sveltePreprocess from 'svelte-preprocess'
const isDev = process.env.NODE_ENV === 'development'
/**
* @param {string} name
* @param {string} path
*
* @returns {import('rollup').RollupOptions}
*/
function makeConfig(name, path) {
return {
input: { [name]: path },
output: {
dir: './plugins',
format: 'iife',
globals: {
'blessing-skin': 'blessing',
react: 'React',
'react-dom': 'ReactDOM',
},
indent: ' ',
},
external: ['react', 'react-dom', 'blessing-skin'],
plugins: [
typescript(),
svelte({
preprocess: sveltePreprocess(),
}),
resolve({ browser: true }),
commonjs(),
!isDev && terser(),
],
}
}
export default glob([
'plugins/*/assets/**/*.ts',
'plugins/*/assets/**/*.tsx',
'!plugins/*/assets/**/*.test.ts',
'!**/*.d.ts',
]).then((files) =>
files.map((file) => {
const name = file.replace('plugins/', '').replace(/\.tsx?$/g, '')
return makeConfig(name, file)
}),
)

View File

@ -8,15 +8,11 @@
"baseUrl": ".",
"paths": {
"blessing-skin": ["./types"]
}
},
"types": ["svelte"]
},
"include": [
"plugins/*/assets",
"types.ts"
],
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
}
]
}

2919
yarn.lock

File diff suppressed because it is too large Load Diff