2020-03-15 00:57:41 +00:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2017-02-21 23:55:11 +00:00
|
|
|
|
2020-03-15 00:57:41 +00:00
|
|
|
module.exports = (env, argv) => {
|
|
|
|
const isDev = argv.mode == "development";
|
|
|
|
|
2021-03-04 15:45:34 +00:00
|
|
|
return {
|
2020-03-15 00:57:41 +00:00
|
|
|
entry: `${__dirname}/src/client.ts`,
|
|
|
|
output: {
|
|
|
|
filename: "client.js",
|
|
|
|
path: __dirname + "/dist/",
|
2021-02-28 22:17:26 +00:00
|
|
|
library: ["FacilMap", "Client"],
|
|
|
|
libraryTarget: "umd",
|
|
|
|
libraryExport: "default"
|
2020-03-15 00:57:41 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [ ".js", ".ts" ]
|
|
|
|
},
|
|
|
|
mode: isDev ? "development" : "production",
|
|
|
|
devtool: isDev ? "cheap-eval-source-map" : "source-map",
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
resource: { and: [ /\.ts/, [
|
|
|
|
__dirname + "/src/"
|
|
|
|
] ] },
|
|
|
|
loader: 'ts-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [ 'style-loader', 'css-loader' ]
|
2018-09-26 22:15:02 +00:00
|
|
|
}
|
2020-03-15 00:57:41 +00:00
|
|
|
]
|
|
|
|
},
|
2021-02-28 22:17:26 +00:00
|
|
|
externals: {
|
|
|
|
"socket.io-client": {
|
|
|
|
commonjs: 'socket.io-client',
|
|
|
|
commonjs2: 'socket.io-client',
|
|
|
|
amd: 'socket.io-client',
|
|
|
|
root: 'io'
|
|
|
|
}
|
|
|
|
},
|
2020-03-15 00:57:41 +00:00
|
|
|
plugins: [
|
|
|
|
//new BundleAnalyzerPlugin()
|
|
|
|
],
|
|
|
|
devServer: {
|
2021-02-28 22:17:26 +00:00
|
|
|
publicPath: "/dist",
|
|
|
|
disableHostCheck: true,
|
|
|
|
injectClient: false // https://github.com/webpack/webpack-dev-server/issues/2484
|
2020-03-15 00:57:41 +00:00
|
|
|
}
|
|
|
|
};
|
2017-02-21 23:55:11 +00:00
|
|
|
};
|