使用rollup.js架构。

This commit is contained in:
liteng 2018-06-07 20:06:04 +08:00
parent 2ecbd4666c
commit 4d48aed6ec
6 changed files with 2487 additions and 268 deletions

18
.babelrc Normal file
View File

@ -0,0 +1,18 @@
{
"presets": [
[
"env",
{
"modules": false
}
]
],
"plugins": [
"external-helpers",
"transform-es2015-arrow-functions",
"syntax-async-functions",
"transform-class-properties",
"transform-export-extensions",
"transform-es2015-template-literals"
]
}

310
.gitignore vendored
View File

@ -1,288 +1,62 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
# Logs
logs
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Chutzpah Test files
_Chutzpah*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Coverage directory used by tools like istanbul
coverage
# TFS 2012 Local Workspace
$tf/
# nyc test coverage
.nyc_output
# Guidance Automation Toolkit
*.gpState
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# Bower dependency directory (https://bower.io/)
bower_components
# JustCode is a .NET coding add-in
.JustCode
# node-waf configuration
.lock-wscript
# TeamCity is a build add-in
_TeamCity*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
# TypeScript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Optional npm cache directory
.npm
# Visual Studio 6 workspace options file
*.opt
# Optional eslint cache
.eslintcache
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Optional REPL history
.node_repl_history
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Output of 'npm pack'
*.tgz
# Paket dependency manager
.paket/paket.exe
paket-files/
# Yarn Integrity file
.yarn-integrity
# FAKE - F# Make
.fake/
# dotenv environment variables file
.env
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# next.js build output
.next
/dist

View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

2324
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

46
package.json Normal file
View File

@ -0,0 +1,46 @@
{
"name": "earth",
"version": "0.0.1",
"private": true,
"description": "GIS project using Three.js.",
"dependencies": {
"d3-dispatch": "^1.0.3",
"http": "0.0.0",
"three": "^0.92.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-env": "^1.7.0",
"rollup": "^0.59.2",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-copy": "^0.2.3",
"rollup-plugin-node-resolve": "^3.3.0"
},
"scripts": {
"build": "rollup -c",
"build-watch": "rollup -c -w",
"clear": "npm prune"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/tengge1/Earth.git"
},
"keywords": [
"earth",
"gis",
"three.js"
],
"author": "tengge",
"license": "MIT",
"bugs": {
"url": "https://github.com/tengge1/Earth/issues"
},
"homepage": "https://github.com/tengge1/Earth"
}

49
rollup.config.js Normal file
View File

@ -0,0 +1,49 @@
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import copy from 'rollup-plugin-copy';
function glsl() {
return {
transform(code, id) {
if (/\.glsl$/.test(id) === false) return;
var transformedCode = 'export default ' + JSON.stringify(
code
.replace(/[ \t]*\/\/.*\n/g, '') // remove //
.replace(/[ \t]*\/\*[\s\S]*?\*\//g, '') // remove /* */
.replace(/\n{2,}/g, '\n') // # \n+ to \n
) + ';';
return {
code: transformedCode,
map: { mappings: '' }
};
}
};
}
export default {
input: 'src/index.js',
output: {
indent: '\t',
format: 'umd',
name: 'E',
file: 'dist/Earth.js'
},
external: [],
plugins: [
glsl(),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true,
externalHelpers: false
}),
resolve({
customResolveOptions: {
moduleDirectory: 'node_modules'
}
}),
copy({
"./assets/": "./dist/assets/"
})
]
};