forked from temporalio/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
112 lines (109 loc) · 2.69 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
extractStylus = 'css-loader?sourceMap!stylus-loader',
development = !['production', 'ci'].includes(process.env.NODE_ENV);
require('babel-polyfill');
const PUBLIC_PATH = process.env.TEMPORAL_WEB_ROOT_PATH || '/';
module.exports = {
devtool: 'source-map',
entry: [
'babel-polyfill',
path.join(
__dirname,
process.env.TEST_RUN ? 'client/test/index' : 'client/main'
),
].filter(x => x),
output: {
path: path.join(__dirname, 'dist', PUBLIC_PATH),
filename: 'temporal.[hash].js',
publicPath: PUBLIC_PATH,
},
plugins: [
new webpack.DefinePlugin({
'process.env.TEMPORAL_WEB_ROOT_PATH': `"${PUBLIC_PATH}"`,
}),
new ExtractTextPlugin({
filename: development ? 'temporal.css' : 'temporal.[hash].css',
allChunks: true,
}),
new HtmlWebpackPlugin({
title: 'Temporal',
filename: 'index.html',
favicon: 'favicon.png',
inject: false,
template: require('html-webpack-template'),
lang: 'en-US',
scripts: (process.env.TEMPORAL_EXTERNAL_SCRIPTS || '')
.split(',')
.filter(x => x),
}),
].filter(x => x),
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
configFile: path.resolve(__dirname, 'babel.config.js'),
},
},
{
test: /\.vue?$/,
loader: 'vue-loader',
options: {
loaders: {
js: {
loader: 'babel-loader',
options: {
configFile: path.resolve(__dirname, 'babel.config.js'),
},
},
stylus: ExtractTextPlugin.extract({
use: extractStylus,
fallback: 'vue-style-loader',
}),
},
},
},
{
test: /\.svg$/,
use: [
{
loader: 'html-loader',
options: {
minimize: true,
},
},
],
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
},
},
{
test: /\.styl$/,
use: ExtractTextPlugin.extract({
use: extractStylus,
fallback: 'raw-loader',
}),
include: path.join(__dirname, 'src'),
},
],
},
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js',
},
extensions: ['*', '.js', '.vue', '.json'],
},
devServer: {
historyApiFallback: true,
overlay: true,
publicPath: PUBLIC_PATH,
},
};