Simplify project config

This commit is contained in:
Aria Minaei 2021-06-18 20:35:01 +02:00
parent c72647c1e5
commit 39a2645d65
27 changed files with 79 additions and 87 deletions

32
theatre/devEnv/build.ts Normal file
View file

@ -0,0 +1,32 @@
import path from 'path'
import {
convertObjectToWebpackDefinePaths,
getEnvConfig,
} from './webpack/createWebpackConfig'
const playgroundDir = path.join(__dirname, '..')
const envConfig = getEnvConfig(true)
require('esbuild').serve(
{
port,
servedir: path.join(playgroundDir, 'src'),
},
{
entryPoints: [path.join(playgroundDir, 'src/index.tsx')],
target: ['firefox88'],
loader: {'.png': 'file'},
// outdir: '.',
// watch: true,
bundle: true,
sourcemap: true,
define: {
global: 'window',
...convertObjectToWebpackDefinePaths({
process: {env: envConfig},
'process.env': envConfig,
}),
},
},
)

View file

@ -24,7 +24,6 @@ export default (type: 'playground' | 'development' | 'production') => {
return bundles.map((which) => {
const envConfig = getEnvConfig(isDev)
envConfig.isCore = which === 'core'
envConfig.version = require('../../package.json').version
const packageRoot = path.join(
privatePackageRoot,
@ -175,12 +174,6 @@ export default (type: 'playground' | 'development' | 'production') => {
}
}
if (which === 'core') {
config.plugins!.push(
new webpack.DefinePlugin({'$env.isCore': JSON.stringify(true)}),
)
}
if (!isDev) {
config.stats = {
// @ts-ignore
@ -196,12 +189,12 @@ export default (type: 'playground' | 'development' | 'production') => {
}
}
// defined process.env and $env
// defined process.env and process.env
config.plugins!.push(
new webpack.DefinePlugin(
convertObjectToWebpackDefinePaths({
process: {env: envConfig},
$env: envConfig,
'process.env': envConfig,
}),
),
)

View file

@ -2,5 +2,4 @@ require('ts-node').register({transpileOnly: true, skipProject: true})
const createWebpackConfigObject = require('./createWebpackConfig')
// @ts-ignore
module.exports = createWebpackConfigObject('production')