ES6模块很容易利用,但是我在如何使它们在dev和prod中都能使用方面很挣扎。在开发人员中,它们存储在Django的静态文件夹中,这意味着我可以这样导入它们:
<Resource name="jdbc/maxpool" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
poolName="ah pool"
idleTimeout="0"
registerMbeans="true"
maximumPoolSize="250"
maxLifetime="3000"
minimumIdle="5"
leakDetectionThreshold="90000"
dataSourceClassName="org.postgresql.ds.PGSimpleDataSource"
dataSource.url="jdbc:postgresql://10.1.1.1:5444/xxxx"
dataSource.user="ereport"
dataSource.password="zzzz"/>
#hibernate.hbm2ddl.auto=create
#hibernate.generate_statistics=true
#hibernate.cache.use_structured_entries=true
#hibernate.ejb.naming_strategy=my.mimos.jpa.naming.CustomImprovedNamingStrategy
javax.persistence.lock.timeout=5000
hibernate.id.new_generator_mappings=true
hibernate.id.optimizer.pooled.prefer_lo=true
hibernate.default_batch_fetch_size=20
hibernate.jdbc.fetch_size=50
hibernate.jdbc.batch_size=60
hibernate.jdbc.lob.non_contextual_creation=true
hibernate.order_inserts=true
#hibernate.connection.release_mode=after_statement
## uncomment the following 2 properties if batch update is required
#hibernate.order_updates=true
#hibernate.jdbc.batch_versioned_data=true
# Hibernate Envers (audit trail) properties
## There are 2 strategies: DefaultAuditStrategy and ValidityAuditStrategy
## ValidityAuditStrategy will store both the start revision and the end revision instead of storing start revision only
org.hibernate.envers.audit_strategy=org.hibernate.envers.strategy.DefaultAuditStrategy
org.hibernate.envers.audit_table_suffix=_h
org.hibernate.envers.do_not_audit_optimistic_locking_field=false
"efamily-persistence.properties" 40L, 2039C
在html模板中:
import { buildTable } from './customTable.js';
但是,在prod中,静态文件夹位于其他Web服务器上,因此这些路径不会相同。使这些模块同时在dev和prod中加载的最佳方法是什么?
答案 0 :(得分:0)
解决方案是使用Django模板语法导入js模块:
<script type="module">
import { buildTable } from '../../static/customTable.js'
example('hello world')
</script>