-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.common.js
108 lines (107 loc) · 2.61 KB
/
webpack.common.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
//@ts-ignore
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const webpack = require('webpack');
module.exports = {
entry: {
index: ['./src/css/index.scss', './src/js/index.tsx'],
},
output: {
filename: '[name].[chunkhash].js',
publicPath: '',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: ['ts-loader'],
exclude: /node_modules/,
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: { minimize: false },
},
],
exclude: /node_modules/,
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.css$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ['file-loader'],
},
{
test: /\.(png|jpg|gif)$/,
use: ['url-loader'],
},
{
test: /\.svg$/,
use: ['file-loader'],
},
{
test: /\.js$/,
include: /node_modules\/(@arcgis|@esri\/calcite-components|@zip.js)/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
compact: true,
sourceType: 'unambiguous',
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin(),
new Dotenv({
systemvars: true,
}),
new HtmlWebPackPlugin({
title: 'ArcGIS Template Application',
template: './src/index.html',
filename: './index.html',
favicon: './src/assets/favicon.ico',
chunksSortMode: 'none',
inlineSource: '.(css)$',
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser.js',
}),
],
resolve: {
fallback: {
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer'),
},
modules: [path.resolve(__dirname, '/src'), path.resolve(__dirname, 'node_modules/')],
extensions: ['.ts', '.tsx', '.js', '.scss', '.css'],
},
};