-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.mjs
More file actions
executable file
·123 lines (121 loc) · 3.98 KB
/
webpack.dev.mjs
File metadata and controls
executable file
·123 lines (121 loc) · 3.98 KB
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
import webpack from 'webpack'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
import { setupMiddlewares } from './demo/server/main.js'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import CopyPlugin from 'copy-webpack-plugin'
import dotenv from 'dotenv'
const __dirname = dirname(fileURLToPath(import.meta.url))
dotenv.config({ path: path.join(__dirname, './.env'), quiet: true })
export default {
mode: 'development',
target: ['web', 'es5'],
entry: {
index: path.join(__dirname, 'demo/js/index.js'),
forms: path.join(__dirname, 'demo/js/forms.js'),
farming: path.join(__dirname, 'demo/js/farming.js'),
planning: path.join(__dirname, 'demo/js/planning.js')
},
output: {
path: path.resolve(__dirname, 'public'),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js'],
alias: {
// Force these to resolve from root node_modules, preventing nested copies
// inside geojson-rbush and mapbox-gl-snap from being bundled separately.
'@turf/meta': path.resolve(__dirname, 'node_modules/@turf/meta'),
'@turf/helpers': path.resolve(__dirname, 'node_modules/@turf/helpers'),
'robust-predicates': path.resolve(__dirname, 'node_modules/robust-predicates')
}
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new CopyPlugin({
patterns: [
{
from: 'node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css',
to: 'assets/govuk-frontend.min.css'
},
{
from: 'node_modules/govuk-frontend/dist/govuk/assets',
to: 'assets'
}
]
}),
new webpack.DefinePlugin({
'process.env': {
// OS Open Zoomstack
OUTDOOR_URL: JSON.stringify(process.env.OUTDOOR_URL),
NIGHT_URL: JSON.stringify(process.env.NIGHT_URL),
DEUTERANOPIA_URL: JSON.stringify(process.env.DEUTERANOPIA_URL),
TRITANOPIA_URL: JSON.stringify(process.env.TRITANOPIA_URL),
// OS Vector Tile API (3857)
VTS_OUTDOOR_URL: JSON.stringify(process.env.VTS_OUTDOOR_URL),
VTS_DARK_URL: JSON.stringify(process.env.VTS_DARK_URL),
VTS_BLACK_AND_WHITE_URL: JSON.stringify(process.env.VTS_BLACK_AND_WHITE_URL),
// OS Vector Tile API (27700)
VTS_OUTDOOR_URL_27700: JSON.stringify(process.env.VTS_OUTDOOR_URL_27700),
VTS_DARK_URL_27700: JSON.stringify(process.env.VTS_DARK_URL_27700),
VTS_BLACK_AND_WHITE_URL_27700: JSON.stringify(process.env.VTS_BLACK_AND_WHITE_URL_27700),
// Aerial photography
AERIAL_URL: JSON.stringify(process.env.AERIAL_URL),
// OS Auth
OS_CLIENT_ID: JSON.stringify(process.env.OS_CLIENT_ID),
OS_CLIENT_SECRET: JSON.stringify(process.env.OS_CLIENT_SECRET),
// OS Names API
OS_NAMES_URL: JSON.stringify(process.env.OS_NAMES_URL),
OS_NEAREST_URL: JSON.stringify(process.env.OS_NEAREST_URL),
// Data services
FARMING_TILE_SERVICE_URL: JSON.stringify(process.env.FARMING_TILE_SERVICE_URL),
FARMING_API_URL: JSON.stringify(process.env.FARMING_API_URL)
}
})
],
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/
},{
test: /\.s[ac]ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
}
],
},
devServer: {
static: [
{
directory: path.join(__dirname, 'demo'),
},
{
directory: path.join(__dirname, 'public'),
},
{
directory: path.join(__dirname, 'assets'),
publicPath: '/assets' // Images served from here as used in both demo and prototype kit plugin
}
],
compress: true,
port: 8080,
open: true,
hot: true,
setupMiddlewares
},
optimization: {
chunkIds: 'named',
splitChunks: {
chunks () {
return false
}
}
}
}