update template projects
This commit is contained in:
parent
f6ce6843e3
commit
650ba64ad6
@ -17,9 +17,10 @@
|
|||||||
"typescript": "^3.7.4"
|
"typescript": "^3.7.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^11.0.1",
|
|
||||||
"@rollup/plugin-node-resolve": "^7.0.0",
|
|
||||||
"@rollup/plugin-buble": "^0.21.0",
|
"@rollup/plugin-buble": "^0.21.0",
|
||||||
"@rollup/plugin-json": "^4.0.2"
|
"@rollup/plugin-commonjs": "^11.0.1",
|
||||||
|
"@rollup/plugin-image": "^2.0.4",
|
||||||
|
"@rollup/plugin-json": "^4.0.2",
|
||||||
|
"@rollup/plugin-node-resolve": "^7.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,8 +3,50 @@ import commonjs from '@rollup/plugin-commonjs'
|
|||||||
import bundles from './build/index'
|
import bundles from './build/index'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
//import babel from 'rollup-plugin-babel';
|
import buble from '@rollup/plugin-buble'
|
||||||
import json from '@rollup/plugin-json'
|
import json from "@rollup/plugin-json"
|
||||||
|
import image from '@rollup/plugin-image'
|
||||||
|
|
||||||
|
function searchImages(dir, images) {
|
||||||
|
const files = fs.readdirSync(dir)
|
||||||
|
files.forEach((item, index) => {
|
||||||
|
var fullPath = path.join(dir, item)
|
||||||
|
const stat = fs.statSync(fullPath)
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
searchImages(path.join(dir, item), images)
|
||||||
|
} else {
|
||||||
|
if(fullPath.endsWith('.png')) {
|
||||||
|
images.push(fullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return images
|
||||||
|
}
|
||||||
|
|
||||||
|
const allImages = []
|
||||||
|
searchImages('src', allImages)
|
||||||
|
|
||||||
|
function mkdirsSync(dirname) {
|
||||||
|
if (fs.existsSync(dirname)) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
if (mkdirsSync(path.dirname(dirname))) {
|
||||||
|
fs.mkdirSync(dirname)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allImages.forEach((value) => {
|
||||||
|
let path = __dirname + '/build/' + value
|
||||||
|
let index = path.lastIndexOf('/')
|
||||||
|
mkdirsSync(path.substring(0, index))
|
||||||
|
|
||||||
|
fs.copyFile(__dirname + '/' + value, __dirname + '/build/' + value, error => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
function readDirs(dirPath, files) {
|
function readDirs(dirPath, files) {
|
||||||
if (fs.statSync(dirPath).isDirectory()) {
|
if (fs.statSync(dirPath).isDirectory()) {
|
||||||
@ -51,15 +93,16 @@ export default
|
|||||||
resolve({ mainFields: ["jsnext"] }),
|
resolve({ mainFields: ["jsnext"] }),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
json(),
|
json(),
|
||||||
|
image(),
|
||||||
],
|
],
|
||||||
external: ['reflect-metadata', 'doric'],
|
external: ['reflect-metadata', 'doric'],
|
||||||
onwarn: function (warning) {
|
onwarn: function (warning) {
|
||||||
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
|
if (warning.code === 'THIS_IS_UNDEFINED') { return }
|
||||||
console.warn(warning.message);
|
console.warn(warning.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// If need ES5 support enable following configs
|
// If need ES5 support enable following configs
|
||||||
// .concat(
|
// .concat(
|
||||||
// allFiles
|
// allFiles
|
||||||
// .map(e => e.replace('.ts', ''))
|
// .map(e => e.replace('.ts', ''))
|
||||||
@ -74,14 +117,16 @@ export default
|
|||||||
// plugins: [
|
// plugins: [
|
||||||
// resolve({ mainFields: ["jsnext"] }),
|
// resolve({ mainFields: ["jsnext"] }),
|
||||||
// commonjs(),
|
// commonjs(),
|
||||||
|
// json(),
|
||||||
// buble({
|
// buble({
|
||||||
// transforms: { dangerousForOf: true }
|
// transforms: { dangerousForOf: true }
|
||||||
// }),
|
// }),
|
||||||
|
// image(),
|
||||||
// ],
|
// ],
|
||||||
// external: ['reflect-metadata', 'doric'],
|
// external: ['reflect-metadata', 'doric'],
|
||||||
// onwarn: function (warning) {
|
// onwarn: function (warning) {
|
||||||
// if (warning.code === 'THIS_IS_UNDEFINED') { return; }
|
// if (warning.code === 'THIS_IS_UNDEFINED') { return }
|
||||||
// console.warn(warning.message);
|
// console.warn(warning.message)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }))
|
// }))
|
Reference in New Issue
Block a user