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'
|
2020-07-08 08:41:20 +00:00
|
|
|
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',
|
2017-05-18 16:24:17 +00:00
|
|
|
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)
|
2017-10-14 19:26:52 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-06-01 22:02:15 +00:00
|
|
|
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`
|
2019-06-01 22:02:15 +00:00
|
|
|
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
|
|
|
},
|
2017-04-27 18:42:11 +00:00
|
|
|
output: {
|
2019-06-01 22:02:15 +00:00
|
|
|
publicPath,
|
2017-04-27 18:42:11 +00:00
|
|
|
},
|
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)$/,
|
2022-06-09 15:49:44 +00:00
|
|
|
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
|
|
|
},
|
2022-02-15 16:33:17 +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
|
|
|
})
|
2016-06-17 18:48:49 +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)$/,
|
2022-06-09 15:49:44 +00:00
|
|
|
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
|
|
|
})
|
2017-04-27 16:18:49 +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,
|
2017-07-13 19:46:45 +00:00
|
|
|
cliConfig,
|
2017-10-14 19:26:52 +00:00
|
|
|
highlighterConfig,
|
2017-07-13 15:15:34 +00:00
|
|
|
]
|