BoostNote-App/webpack.config.ts

120 lines
2.7 KiB
TypeScript
Raw Normal View History

2019-09-18 05:25:34 +03:00
import path from 'path'
import webpack from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'
2019-09-18 11:36:21 +03:00
import express from 'express'
import ErrorOverlayPlugin from 'error-overlay-webpack-plugin'
import CopyPlugin from 'copy-webpack-plugin'
2018-11-06 10:27:04 +03:00
module.exports = {
entry: [
'react-hot-loader/patch',
// activate HMR for React
'webpack-dev-server/client?http://localhost:3000',
// bundle the client for webpack-dev-server
// and connect to the provided endpoint
'webpack/hot/only-dev-server',
// bundle the client for hot reloading
// only- means to only hot reload for successful updates
2019-08-26 11:36:58 +03:00
'./src/index.tsx'
2018-11-06 10:27:04 +03:00
// the entry point of our app
],
output: {
filename: 'bundle.js',
// the output bundle
path: path.resolve(__dirname, 'dist'),
2019-10-11 11:42:29 +03:00
publicPath: '/app'
2018-11-06 10:27:04 +03:00
// necessary for HMR to know where to load the hot update chunks
},
devtool: 'inline-source-map',
module: {
rules: [
2019-09-18 11:36:21 +03:00
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
loader: 'url-loader',
options: {
limit: 8192
}
},
2018-11-06 10:27:04 +03:00
{
test: /\.tsx?$/,
use: [{ loader: 'ts-loader' }],
2018-11-06 10:27:04 +03:00
exclude: /node_modules/
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
// enable HMR globally
new webpack.NamedModulesPlugin(),
// prints more readable module names in the browser console on HMR updates
new webpack.NoEmitOnErrorsPlugin(),
// do not emit compiled assets that include errors
new HtmlWebpackPlugin(),
2019-10-30 16:20:21 +03:00
new ErrorOverlayPlugin(),
2019-11-13 11:17:48 +03:00
new webpack.EnvironmentPlugin([
'NODE_ENV',
'AMPLIFY_AUTH_IDENTITY_POOL_ID',
'AMPLIFY_AUTH_REGION',
'AMPLIFY_PINPOINT_APPID',
'AMPLIFY_PINPOINT_REGION',
'BOOST_NOTE_BASE_URL'
]),
new CopyPlugin([
{
from: path.join(__dirname, 'node_modules/codemirror/theme'),
to: 'codemirror/theme'
}
])
2018-11-06 10:27:04 +03:00
],
devServer: {
host: 'localhost',
port: 3000,
2019-10-11 11:42:29 +03:00
historyApiFallback: {
index: '/app'
},
2018-11-06 10:27:04 +03:00
// respond to 404s with index.html
2019-09-18 11:36:21 +03:00
hot: true,
2018-11-06 10:27:04 +03:00
// enable HMR on the server
2019-09-18 11:36:21 +03:00
2019-12-04 20:23:55 +03:00
before: function(app, server) {
2019-09-18 11:36:21 +03:00
app.use(
'/codemirror/mode',
express.static(path.join(__dirname, 'node_modules/codemirror/mode'))
)
app.use(
'/codemirror/addon',
express.static(path.join(__dirname, 'node_modules/codemirror/addon'))
)
app.use(
'/codemirror/theme',
express.static(path.join(__dirname, 'node_modules/codemirror/theme'))
)
2019-09-18 11:36:21 +03:00
}
2018-11-06 10:27:04 +03:00
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
2019-08-29 07:46:14 +03:00
},
node: {
fs: 'empty'
2018-11-06 10:27:04 +03:00
}
}