Selaa lähdekoodia

修改wepack配置

tags/1.10.2
Caven Chen 5 vuotta sitten
vanhempi
commit
7327e42b74
10 muutettua tiedostoa jossa 164 lisäystä ja 98 poistoa
  1. 7
    0
      CHANGE.md
  2. 5
    5
      dist/dc.base.min.js
  3. 1
    1
      dist/dc.core.min.js
  4. 2
    2
      package.json
  5. 22
    25
      src/base/index.js
  6. 0
    2
      src/core/index.js
  7. 12
    11
      src/core/widget/Compass.js
  8. 4
    4
      src/log.js
  9. 105
    0
      webpack.base.conf.js
  10. 6
    48
      webpack.config.js

+ 7
- 0
CHANGE.md Näytä tiedosto

@@ -1,5 +1,12 @@
# 更新

## 1.10.2

### 2020-9-12

> 1. 完善罗盘功能
> 2. 修改框架包node下导入的方式

## 1.10.1

### 2020-9-12

+ 5
- 5
dist/dc.base.min.js
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
dist/dc.core.min.js
File diff suppressed because it is too large
Näytä tiedosto


+ 2
- 2
package.json Näytä tiedosto

@@ -17,8 +17,8 @@
"license": "Apache 2.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "yarn run clean && webpack --mode development",
"publish": "yarn run clean && webpack --mode production --env.production",
"build": "yarn run clean && webpack --config webpack.base.conf --mode development && webpack --config webpack.config --mode development",
"publish": "yarn run clean && webpack --config webpack.base.conf --mode production --env.production && webpack --config webpack.config --mode production --env.production",
"clean": "rimraf dist/"
},
"devDependencies": {

+ 22
- 25
src/base/index.js Näytä tiedosto

@@ -5,38 +5,35 @@

import { initMixin, initUse } from './global-api'

delete window.DC

let DC = {
Author: 'Caven Chen <cavencj@gmail.com>',
GitHub: 'https://github.com/dvgis/dc-sdk',
Home: 'https://www.dvgis.cn',
Author: build.author,
GitHub: build.repository,
Home: build.homepage,
Version: build.version,
Namespace: {},
Initialized: false
}

window.DC = DC
;(function() {
require('../log')
initMixin(window.DC)
initUse(window.DC)
let cesiumLoaded = false
DC.init = callback => {
if (!cesiumLoaded) {
new Promise((resolve, reject) => {
let Cesium = require('cesium/Cesium')
resolve(Cesium)
}).then(Cesium => {
DC.Namespace['Cesium'] = Cesium
cesiumLoaded = true
delete window.Cesium
callback && callback()
})
} else {
initMixin(DC)
initUse(DC)

let cesiumLoaded = false
DC.init = callback => {
if (!cesiumLoaded) {
new Promise((resolve, reject) => {
let Cesium = require('cesium/Cesium')
resolve(Cesium)
}).then(Cesium => {
DC.Namespace['Cesium'] = Cesium
cesiumLoaded = true
delete window.Cesium
callback && callback()
}
})
} else {
callback && callback()
}
})()
}

require('../log')

export default DC

+ 0
- 2
src/core/index.js Näytä tiedosto

@@ -24,7 +24,6 @@ const install = function(DC) {
}
callback && callback()
} catch (e) {
delete window.DC
// eslint-disable-next-line no-console
console.error(e)
}
@@ -32,7 +31,6 @@ const install = function(DC) {
}

/* istanbul ignore if */

if (typeof window !== 'undefined' && window.DC) {
install(window.DC)
}

+ 12
- 11
src/core/widget/Compass.js Näytä tiedosto

@@ -4,6 +4,7 @@
*/

import { DomUtil } from '../utils'
import { SceneEventType } from '../event'
import Icon from '../icon'
import State from '../state/State'
import Widget from './Widget'
@@ -32,20 +33,11 @@ class Compass extends Widget {
}

_bindEvent() {
this._removeSubscription = this._viewer.scene.postRender.addEventListener(
() => {
let heading = this._viewer.camera.heading
this._outRing.style.cssText = `
transform : rotate(-${heading}rad);
-webkit-transform : rotate(-${heading}rad);
`
},
this
)
this._viewer.on(SceneEventType.POST_RENDER, this._postRenderHandler, this)
}

_unbindEvent() {
this._removeSubscription()
this._viewer.off(SceneEventType.POST_RENDER, this._postRenderHandler, this)
}

_installHook() {
@@ -58,6 +50,15 @@ class Compass extends Widget {
}
}

_postRenderHandler() {
let heading = this._viewer.camera.heading
this._outRing &&
(this._outRing.style.cssText = `
transform : rotate(-${heading}rad);
-webkit-transform : rotate(-${heading}rad);
`)
}

_createCompassDom() {
DomUtil.create('div', 'out-ring-bg', this._wrapper)
this._outRing = DomUtil.parseDom(Icon.compass_outer, true, 'out-ring')

+ 4
- 4
src/log.js Näytä tiedosto

@@ -9,12 +9,12 @@ console.clear()
// eslint-disable-next-line no-console
console.log(
`%c \n DC-SDK \n %c \n 用数字描绘世界之美 %c \n
版本:${DC.Version}
版本:${build.version}
编译日期:${build.time}
Cesium版本:1.73
作者:${DC.Author}
主页: ${DC.Home}
github:${DC.GitHub}
作者:${build.author}
主页: ${build.homepage}
github:${build.repository}
授权信息:授权-永久使用此软件当前版本。 \n

版权声明:

+ 105
- 0
webpack.base.conf.js Näytä tiedosto

@@ -0,0 +1,105 @@
/**
* @Author: Caven
* @Date: 2020-01-18 19:22:23
*/

const path = require('path')
const webpack = require('webpack')
const packageInfo = require('./package.json')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const cesiumBuild = 'node_modules/cesium/Build/Cesium'

let cesiumCopyPlugin = [
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'Assets'), to: 'resources/Assets' }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'Workers'), to: 'resources/Workers' }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'ThirdParty'), to: 'resources/ThirdParty' }
])
]

function resolve(dir) {
return path.join(__dirname, '.', dir)
}

function getTime() {
let now = new Date()
let m = now.getMonth() + 1
m = m < 10 ? '0' + m : m
let d = now.getDate()
d = d < 10 ? '0' + d : d
let h = now.getHours()
h = h < 10 ? '0' + h : h
let min = now.getMinutes()
min = min < 10 ? '0' + min : min
let s = now.getSeconds()
s = s < 10 ? '0' + s : s
return `${now.getFullYear()}-${m}-${d} ${h}:${min}:${s}`
}

module.exports = env => {
const IS_PROD = (env && env.production) || false
const publicPath = IS_PROD ? '/' : '/'
let plugins = [
...cesiumCopyPlugin,
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('./libs/dc-sdk/resources/'),
'build.version': JSON.stringify(packageInfo.version),
'build.time': JSON.stringify(getTime()),
'build.author': JSON.stringify(packageInfo.author),
'build.repository': JSON.stringify(packageInfo.repository),
'build.homepage': JSON.stringify(packageInfo.homepage)
})
]
if (IS_PROD) {
plugins.push(new webpack.NoEmitOnErrorsPlugin())
}
return {
entry: {
'dc.base': ['base']
},
devtool: IS_PROD ? false : 'source-map',
output: {
filename: IS_PROD ? '[name].min.js' : '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: publicPath,
library: 'DC',
libraryExport: 'default',
libraryTarget: 'umd'
},
amd: {
toUrlUndefined: true
},
node: {
fs: 'empty'
},
module: {
unknownContextCritical: false,
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/transform-runtime'],
compact: false,
ignore: ['checkTree']
}
}
]
},
resolve: {
extensions: ['.js', '.json', '.css'],
alias: {
'@': resolve('src'),
base: './src/base/index.js',
cesium: path.resolve(__dirname, cesiumBuild)
}
},
plugins
}
}

+ 6
- 48
webpack.config.js Näytä tiedosto

@@ -5,58 +5,22 @@

const path = require('path')
const webpack = require('webpack')
const packageInfo = require('./package.json')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const JavaScriptObfuscator = require('webpack-obfuscator')

const cesiumBuild = 'node_modules/cesium/Build/Cesium'

let cesiumCopyPlugin = [
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'Assets'), to: 'resources/Assets' }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'Workers'), to: 'resources/Workers' }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumBuild, 'ThirdParty'), to: 'resources/ThirdParty' }
])
]

function resolve(dir) {
return path.join(__dirname, '.', dir)
}

function getTime() {
let now = new Date()
let m = now.getMonth() + 1
m = m < 10 ? '0' + m : m
let d = now.getDate()
d = d < 10 ? '0' + d : d
let h = now.getHours()
h = h < 10 ? '0' + h : h
let min = now.getMinutes()
min = min < 10 ? '0' + min : min
let s = now.getSeconds()
s = s < 10 ? '0' + s : s
return `${now.getFullYear()}-${m}-${d} ${h}:${min}:${s}`
}

module.exports = env => {
const IS_PROD = (env && env.production) || false
const publicPath = IS_PROD ? '/' : '/'
let plugins = [
...cesiumCopyPlugin,
new MiniCssExtractPlugin({
filename: IS_PROD ? '[name].min.css' : '[name].css',
allChunks: true
}),
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('./libs/dc-sdk/resources/'),
'build.version': JSON.stringify(packageInfo.version),
'build.time': JSON.stringify(getTime())
})
]
if (IS_PROD) {
@@ -67,27 +31,22 @@ module.exports = env => {
{
rotateStringArray: true
},
['dc.base.min.js']
[]
)
)
}
return {
entry: {
'dc.base': ['base'],
'dc.core': ['entry', 'theme']
'dc.core': ['theme', 'entry']
},
devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
devtool: IS_PROD ? false : 'source-map',
output: {
filename: IS_PROD ? '[name].min.js' : '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: publicPath,
sourcePrefix: ''
},
amd: {
toUrlUndefined: true
},
node: {
fs: 'empty'
library: 'DcCore',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
unknownContextCritical: false,
@@ -144,7 +103,6 @@ module.exports = env => {
extensions: ['.js', '.json', '.css'],
alias: {
'@': resolve('src'),
base: './src/base/index.js',
entry: './src/core/index.js',
theme: './src/themes/index.js',
cesium: path.resolve(__dirname, cesiumBuild)

Loading…
Peruuta
Tallenna