-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
151 lines (139 loc) · 4.98 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* Copyright 2016, RadiantBlue Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
'use strict'
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const childProcess = require('child_process')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cssnext = require('postcss-cssnext')
const cssimport = require('postcss-import')
const pkg = require('./package')
const __environment__ = process.env.NODE_ENV || 'development'
const COMPILER_TARGET = process.env.COMPILER_TARGET || (__environment__ === 'development' ? 'es6' : 'es5')
module.exports = {
devtool: 'cheap-module-source-map',
context: __dirname,
entry: './src/index.tsx',
/*externals: {
'openlayers': 'ol'
},*/
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'tslint-loader',
enforce: 'pre',
exclude: /node_modules/
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
'compilerOptions': {
target: COMPILER_TARGET,
},
},
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader'],
include: /node_modules/
},
{
test: /\.css$/,
loaders: [
'style-loader',
{
loader: 'css-loader',
options: {
'module': true,
'localIdentName': '[name]-[local]',
'importLoaders': 1,
},
},
{
loader: 'postcss-loader',
options: {
'plugins': (webpack_) => ([
cssimport({ addDependencyTo: webpack_ }),
cssnext({ browsers: 'Firefox >= 38, Chrome >= 40' }),
]),
},
},
],
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader'
},
{
test: /\.(otf|eot|svg|ttf|woff)[^/]*$/,
loader: 'file-loader'
},
]
},
plugins: [
/*
new CopyWebpackPlugin([{
from: require.resolve('ol/dist/ol-debug.js'),
to: 'ol.js',
}]),
*/
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(__environment__),
'process.env.API_ROOT': process.env.API_ROOT ? JSON.stringify(process.env.API_ROOT) : (__environment__ === 'development') ? JSON.stringify('https://localhost:5000') : "'https://' + location.hostname.replace('beachfront', 'bf-api')",
'process.env.CLASSIFICATION_BANNER_BACKGROUND': JSON.stringify(process.env.CLASSIFICATION_BANNER_BACKGROUND || 'green'),
'process.env.CLASSIFICATION_BANNER_FOREGROUND': JSON.stringify(process.env.CLASSIFICATION_BANNER_FOREGROUND || 'white'),
'process.env.CLASSIFICATION_BANNER_TEXT': JSON.stringify(process.env.CLASSIFICATION_BANNER_TEXT || 'UNCLASSIFIED // TESTING & DEVELOPMENT USE ONLY'),
'process.env.CONSENT_BANNER_TEXT': JSON.stringify(process.env.CONSENT_BANNER_TEXT || '<p>Users must accept the terms and conditions of the User Agreement before signing in to Beachfront. Contact us for account help.</p>'),
'process.env.OSM_BASE_URL': JSON.stringify(process.env.OSM_BASE_URL || 'osm.geointservices.io'),
'process.env.PLANET_BASE_URL': JSON.stringify(process.env.PLANET_BASE_URL || 'planet.com'),
'process.env.USER_GUIDE_URL': '"https://" + location.hostname.replace("beachfront", "bf-docs")',
'process.env.GEOSERVER_WORKSPACE_NAME': JSON.stringify(process.env.GEOSERVER_WORKSPACE_NAME || 'piazza'),
'process.env.GEOSERVER_LAYERGROUP_NAME': JSON.stringify(process.env.GEOSERVER_LAYERGROUP_NAME || 'bfdetections'),
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
favicon: __environment__ === 'production' ? 'src/images/favicon.png' : 'src/images/favicon-dev.png',
hash: true,
xhtml: true,
build: [
pkg.version,
childProcess.execSync('git rev-parse HEAD').toString().trim(),
].join(':')
}),
]
}
if (__environment__ === 'production') {
module.exports.devtool = 'source-map'
module.exports.plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: true, compress: { warnings: false } }))
}