UNPKG

1.85 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
6
7var _webpack = _interopRequireDefault(require("webpack"));
8
9var _path = _interopRequireDefault(require("path"));
10
11var _checkSetup = require("@sharyn/check-setup");
12
13var _appRootPath = require("app-root-path");
14
15var _wdsUtil = require("./wds-util");
16
17/* eslint-disable import/no-extraneous-dependencies, global-require, import/no-dynamic-require, no-empty */
18// flow-disable-next-line
19var config = {
20 entry: './src/_client/client.js',
21 output: {
22 filename: "js/bundle.js",
23 chunkFilename: '[name].[chunkhash].js',
24 path: _path.default.resolve('dist'),
25 publicPath: '/static/'
26 },
27 module: {
28 rules: [{
29 test: /\.js$/,
30 exclude: /node_modules/,
31 use: {
32 loader: 'babel-loader'
33 }
34 }]
35 },
36 plugins: [],
37 resolve: {
38 alias: {
39 joi: 'joi-browser'
40 }
41 },
42 performance: {
43 hints: false
44 }
45};
46var packageJson;
47
48try {
49 // flow-disable-next-line
50 packageJson = require("".concat(_appRootPath.path, "/package.json"));
51} catch (err) {}
52
53if (packageJson && packageJson.version) {
54 config.plugins.push(new _webpack.default.DefinePlugin({
55 CLIENT_VERSION: (0, _stringify.default)(packageJson.version)
56 }));
57}
58
59if ((0, _checkSetup.hasPackage)('compression-webpack-plugin')) {
60 // flow-disable-next-line
61 var CompressionPlugin = require('compression-webpack-plugin');
62
63 config.plugins.push(new CompressionPlugin());
64}
65
66if (_wdsUtil.WDS_PORT) {
67 config.output.publicPath = "http://localhost:".concat(_wdsUtil.WDS_PORT, "/static/");
68 config.devServer = {
69 port: _wdsUtil.WDS_PORT,
70 headers: {
71 'Access-Control-Allow-Origin': '*'
72 }
73 };
74}
75
76module.exports = config;
\No newline at end of file