github-desktop/app/webpack.development.ts

97 lines
2.3 KiB
TypeScript
Raw Normal View History

2017-10-28 18:08:07 +00:00
import * as common from './webpack.common'
2016-05-24 19:12:06 +00:00
2017-10-28 18:08:07 +00:00
import * as webpack from 'webpack'
import merge from 'webpack-merge'
2016-05-24 19:12:06 +00:00
2017-10-28 18:08:07 +00:00
const config: webpack.Configuration = {
2018-05-04 06:16:32 +00:00
mode: 'development',
devtool: 'source-map',
2016-05-11 16:16:32 +00:00
}
2017-04-17 20:24:00 +00:00
const mainConfig = merge({}, common.main, config)
2017-06-06 19:29:05 +00:00
const cliConfig = merge({}, common.cli, config)
const highlighterConfig = merge({}, common.highlighter, config)
2017-04-17 20:24:00 +00:00
2018-05-24 01:04:35 +00:00
const getRendererEntryPoint = () => {
2022-02-14 17:22:25 +00:00
const entry = common.renderer.entry as webpack.EntryObject
2018-05-24 01:04:35 +00:00
if (entry == null) {
throw new Error(
`Unable to resolve entry point. Check webpack.common.ts and try again`
)
}
return entry.renderer as string
}
const getPortOrDefault = () => {
const port = process.env.PORT
if (port != null) {
const result = parseInt(port)
if (isNaN(result)) {
throw new Error(`Unable to parse '${port}' into valid number`)
}
return result
}
return 3000
}
const port = getPortOrDefault()
2019-06-28 13:01:21 +00:00
const webpackHotModuleReloadUrl = `webpack-hot-middleware/client?path=http://localhost:${port}/__webpack_hmr`
const publicPath = `http://localhost:${port}/build/`
2017-04-17 20:24:00 +00:00
const rendererConfig = merge({}, common.renderer, config, {
entry: {
2018-05-24 01:04:35 +00:00
renderer: [webpackHotModuleReloadUrl, getRendererEntryPoint()],
2017-04-17 20:24:00 +00:00
},
output: {
publicPath,
},
2017-04-17 20:24:00 +00:00
module: {
rules: [
// This will cause the compiled CSS (and sourceMap) to be
// embedded within the compiled javascript bundle and added
// as a blob:// uri at runtime.
{
test: /\.(scss|css)$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { sourceMap: true } },
'sass-loader?sourceMap',
],
2017-07-13 15:15:34 +00:00
},
],
2017-04-17 20:24:00 +00:00
},
infrastructureLogging: {
level: 'error',
},
2017-07-13 15:15:34 +00:00
plugins: [new webpack.HotModuleReplacementPlugin()],
2016-06-24 15:48:43 +00:00
})
2017-05-22 07:59:38 +00:00
const crashConfig = merge({}, common.crash, config, {
module: {
rules: [
// This will cause the compiled CSS (and sourceMap) to be
// embedded within the compiled javascript bundle and added
// as a blob:// uri at runtime.
{
test: /\.(scss|css)$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { sourceMap: true } },
'sass-loader?sourceMap',
],
2017-07-13 15:15:34 +00:00
},
],
},
2017-05-22 07:59:38 +00:00
})
2020-07-10 19:22:20 +00:00
// eslint-disable-next-line no-restricted-syntax
export default [
2017-07-13 15:15:34 +00:00
mainConfig,
rendererConfig,
crashConfig,
cliConfig,
highlighterConfig,
2017-07-13 15:15:34 +00:00
]