mirror of https://github.com/tauri-apps/tauri
refactor(tauri.js) keep folder structure on /dist (#235)
This commit is contained in:
parent
4bce0df301
commit
7845ec0e7a
|
@ -20,6 +20,6 @@ if (argv.help) {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const build = require('../dist/build')
|
const build = require('../dist/api/build')
|
||||||
|
|
||||||
build({ ctx: { debug: argv.debug } })
|
build({ ctx: { debug: argv.debug } })
|
||||||
|
|
|
@ -19,6 +19,6 @@ if (argv.help) {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const dev = require('../dist/dev')
|
const dev = require('../dist/api/dev')
|
||||||
|
|
||||||
dev()
|
dev()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const parseArgs = require('minimist')
|
const parseArgs = require('minimist')
|
||||||
const { tauricon } = require('../dist/tauricon')
|
const { tauricon } = require('../dist/api/tauricon')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {object}
|
* @type {object}
|
||||||
|
|
|
@ -39,7 +39,7 @@ if (argv.help) {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const init = require('../dist/init')
|
const init = require('../dist/api/init')
|
||||||
|
|
||||||
init({
|
init({
|
||||||
directory: argv.d || process.cwd(),
|
directory: argv.d || process.cwd(),
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
"lint-staged": "9.5.0",
|
"lint-staged": "9.5.0",
|
||||||
"lockfile-lint": "3.0.3",
|
"lockfile-lint": "3.0.3",
|
||||||
"promise": "8.0.3",
|
"promise": "8.0.3",
|
||||||
|
"raw-loader": "^4.0.0",
|
||||||
"ts-loader": "6.2.1",
|
"ts-loader": "6.2.1",
|
||||||
"typescript": "3.7.3",
|
"typescript": "3.7.3",
|
||||||
"webpack": "4.41.4",
|
"webpack": "4.41.4",
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { TauriConfig } from 'types'
|
import { TauriConfig } from 'types'
|
||||||
import merge from 'webpack-merge'
|
import merge from 'webpack-merge'
|
||||||
import * as entry from '../entry'
|
|
||||||
import { tauriDir } from '../helpers/app-paths'
|
|
||||||
const getTauriConfig = require('../helpers/tauri-config')
|
const getTauriConfig = require('../helpers/tauri-config')
|
||||||
import Runner from '../runner'
|
import Runner from '../runner'
|
||||||
|
|
||||||
|
@ -18,7 +16,5 @@ module.exports = async (config: TauriConfig): Promise<void> => {
|
||||||
) as TauriConfig
|
) as TauriConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
entry.generate(tauriDir, tauriConfig)
|
|
||||||
|
|
||||||
return tauri.build(tauriConfig)
|
return tauri.build(tauriConfig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { TauriConfig } from 'types'
|
import { TauriConfig } from 'types'
|
||||||
import merge from 'webpack-merge'
|
import merge from 'webpack-merge'
|
||||||
import * as entry from '../entry'
|
|
||||||
import { tauriDir } from '../helpers/app-paths'
|
|
||||||
const getTauriConfig = require('../helpers/tauri-config')
|
const getTauriConfig = require('../helpers/tauri-config')
|
||||||
import Runner from '../runner'
|
import Runner from '../runner'
|
||||||
|
|
||||||
|
@ -19,7 +17,5 @@ module.exports = async (config: TauriConfig): Promise<void> => {
|
||||||
) as TauriConfig
|
) as TauriConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
entry.generate(tauriDir, tauriConfig)
|
|
||||||
|
|
||||||
return tauri.run(tauriConfig)
|
return tauri.run(tauriConfig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
import { ensureDirSync, readFileSync, writeFileSync } from 'fs-extra'
|
import { ensureDirSync, writeFileSync } from 'fs-extra'
|
||||||
import compileTemplate from 'lodash.template'
|
import compileTemplate from 'lodash.template'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { TauriConfig } from './types/config'
|
import { TauriConfig } from './types/config'
|
||||||
|
|
||||||
export const generate = (outDir: string, cfg: TauriConfig): void => {
|
export const generate = (outDir: string, cfg: TauriConfig): void => {
|
||||||
// this MUST be from the templates repo
|
// this MUST be from the templates repo
|
||||||
const apiTemplate = readFileSync(
|
const apiTemplate = require('../templates/tauri.js').default
|
||||||
path.resolve(__dirname, '../templates/tauri.js'),
|
|
||||||
'utf-8'
|
|
||||||
)
|
|
||||||
const apiContent = compileTemplate(apiTemplate)(cfg)
|
const apiContent = compileTemplate(apiTemplate)(cfg)
|
||||||
|
|
||||||
ensureDirSync(outDir)
|
ensureDirSync(outDir)
|
||||||
|
|
|
@ -47,6 +47,8 @@ class Runner {
|
||||||
this.__whitelistApi(cfg, toml)
|
this.__whitelistApi(cfg, toml)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
entry.generate(tauriDir, cfg)
|
||||||
|
|
||||||
const runningDevServer = devPath.startsWith('http')
|
const runningDevServer = devPath.startsWith('http')
|
||||||
let inlinedAssets: string[] = []
|
let inlinedAssets: string[] = []
|
||||||
|
|
||||||
|
@ -56,8 +58,6 @@ class Runner {
|
||||||
|
|
||||||
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
|
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
|
||||||
|
|
||||||
entry.generate(tauriDir, cfg)
|
|
||||||
|
|
||||||
this.devPath = devPath
|
this.devPath = devPath
|
||||||
|
|
||||||
const features = runningDevServer ? ['dev-server'] : []
|
const features = runningDevServer ? ['dev-server'] : []
|
||||||
|
@ -121,12 +121,11 @@ class Runner {
|
||||||
this.__whitelistApi(cfg, toml)
|
this.__whitelistApi(cfg, toml)
|
||||||
})
|
})
|
||||||
|
|
||||||
const inlinedAssets = await this.__parseHtml(cfg, cfg.build.distDir)
|
|
||||||
|
|
||||||
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
|
|
||||||
|
|
||||||
entry.generate(tauriDir, cfg)
|
entry.generate(tauriDir, cfg)
|
||||||
|
|
||||||
|
const inlinedAssets = await this.__parseHtml(cfg, cfg.build.distDir)
|
||||||
|
process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
|
||||||
|
|
||||||
const features = [
|
const features = [
|
||||||
cfg.tauri.embeddedServer.active ? 'embedded-server' : 'no-server'
|
cfg.tauri.embeddedServer.active ? 'embedded-server' : 'no-server'
|
||||||
]
|
]
|
||||||
|
@ -163,7 +162,7 @@ class Runner {
|
||||||
const distIndexPath = path.join(indexDir, 'index.html')
|
const distIndexPath = path.join(indexDir, 'index.html')
|
||||||
if (!existsSync(distIndexPath)) {
|
if (!existsSync(distIndexPath)) {
|
||||||
warn(
|
warn(
|
||||||
`Error: cannot find index.html in "${indexDir}". Did you forget to build your web code or update the build.distDir in tauri.conf.js?`
|
`Error: cannot find index.html in "${indexDir}". Did you forget to build your web code or update the build.distDir in tauri.conf.json?`
|
||||||
)
|
)
|
||||||
reject(new Error('Could not find index.html in dist dir.'))
|
reject(new Error('Could not find index.html in dist dir.'))
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ Run \`tauri init --force template\` to overwrite.`)
|
||||||
try {
|
try {
|
||||||
removeSync(dir)
|
removeSync(dir)
|
||||||
copyTemplates({
|
copyTemplates({
|
||||||
source: resolve(__dirname, '../templates/src-tauri'),
|
source: resolve(__dirname, '../../templates/src-tauri'),
|
||||||
scope: {
|
scope: {
|
||||||
tauriDep
|
tauriDep
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,11 +3,11 @@ const nodeExternals = require('webpack-node-externals')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
build: './src/api/build.ts',
|
'api/build': './src/api/build.ts',
|
||||||
dev: './src/api/dev.ts',
|
'api/dev': './src/api/dev.ts',
|
||||||
init: './src/api/init.ts',
|
'api/init': './src/api/init.ts',
|
||||||
tauricon: './src/api/tauricon.ts',
|
'api/tauricon': './src/api/tauricon.ts',
|
||||||
'tauri-config': './src/helpers/tauri-config.ts'
|
'helpers/tauri-config': './src/helpers/tauri-config.ts'
|
||||||
},
|
},
|
||||||
mode: process.env.NODE_ENV || 'development',
|
mode: process.env.NODE_ENV || 'development',
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
@ -17,6 +17,10 @@ module.exports = {
|
||||||
test: /\.tsx?$/,
|
test: /\.tsx?$/,
|
||||||
use: 'ts-loader',
|
use: 'ts-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /tauri\.js$/i,
|
||||||
|
loader: 'raw-loader'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -6678,6 +6678,14 @@ randomfill@^1.0.3:
|
||||||
randombytes "^2.0.5"
|
randombytes "^2.0.5"
|
||||||
safe-buffer "^5.1.0"
|
safe-buffer "^5.1.0"
|
||||||
|
|
||||||
|
raw-loader@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.0.tgz#d639c40fb9d72b5c7f8abc1fb2ddb25b29d3d540"
|
||||||
|
integrity sha512-iINUOYvl1cGEmfoaLjnZXt4bKfT2LJnZZib5N/LLyAphC+Dd11vNP9CNVb38j+SAJpFI1uo8j9frmih53ASy7Q==
|
||||||
|
dependencies:
|
||||||
|
loader-utils "^1.2.3"
|
||||||
|
schema-utils "^2.5.0"
|
||||||
|
|
||||||
rc@^1.0.1, rc@^1.2.7:
|
rc@^1.0.1, rc@^1.2.7:
|
||||||
version "1.2.8"
|
version "1.2.8"
|
||||||
resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
|
resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
|
||||||
|
@ -7139,6 +7147,14 @@ schema-utils@^1.0.0:
|
||||||
ajv-errors "^1.0.0"
|
ajv-errors "^1.0.0"
|
||||||
ajv-keywords "^3.1.0"
|
ajv-keywords "^3.1.0"
|
||||||
|
|
||||||
|
schema-utils@^2.5.0:
|
||||||
|
version "2.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.6.1.tgz#eb78f0b945c7bcfa2082b3565e8db3548011dc4f"
|
||||||
|
integrity sha512-0WXHDs1VDJyo+Zqs9TKLKyD/h7yDpHUhEFsM2CzkICFdoX1av+GBq/J2xRTFfsQO5kBfhZzANf2VcIm84jqDbg==
|
||||||
|
dependencies:
|
||||||
|
ajv "^6.10.2"
|
||||||
|
ajv-keywords "^3.4.1"
|
||||||
|
|
||||||
seek-bzip@^1.0.5:
|
seek-bzip@^1.0.5:
|
||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
resolved "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc"
|
resolved "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc"
|
||||||
|
|
Loading…
Reference in New Issue