forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
68 lines (56 loc) · 1.88 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// webpack config to build UI bundles and assets
'use strict'
const path = require('path')
const webpack = require('webpack')
const webpackMerge = require('webpack-merge')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const WorkerPlugin = require('worker-plugin')
const { DEV_MODE, baseConfig } = require('@opentrons/webpack-config')
const { productName: title } = require('@opentrons/app-shell/package.json')
const { description, author } = require('./package.json')
const JS_ENTRY = path.join(__dirname, 'src/index.js')
const HTML_ENTRY = path.join(__dirname, 'src/index.hbs')
const OUTPUT_PATH = path.join(__dirname, 'dist')
const PORT = process.env.PORT || 8080
const CONTENT_BASE = path.join(__dirname, './src')
const PUBLIC_PATH = DEV_MODE ? `http://localhost:${PORT}/` : ''
module.exports = webpackMerge(baseConfig, {
entry: [JS_ENTRY],
output: Object.assign({
path: OUTPUT_PATH,
publicPath: PUBLIC_PATH,
}),
plugins: [
new webpack.EnvironmentPlugin(
Object.keys(process.env)
.filter(v => v.startsWith('OT_APP'))
.concat(['NODE_ENV'])
),
new WorkerPlugin({
// disable warnings about HMR when we're in prod
globalObject: DEV_MODE ? 'self' : false,
// add required JS plugins to child compiler
plugins: ['EnvironmentPlugin'],
}),
new HtmlWebpackPlugin({
title,
description,
author,
template: HTML_ENTRY,
intercomId: process.env.OT_APP_INTERCOM_ID,
}),
new ScriptExtHtmlWebpackPlugin({ defaultAttribute: 'defer' }),
],
node: {
__filename: true,
// use userland events because webpack's is out of date
// https://github.com/webpack/node-libs-browser/issues/78
events: false,
},
devServer: {
port: PORT,
publicPath: PUBLIC_PATH,
contentBase: [CONTENT_BASE],
},
})