-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
100 lines (97 loc) · 3.31 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
// Copyright (c) individual contributors.
// All rights reserved.
//
// This is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of
// the License, or any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. A copy of the
// GNU Lesser General Public License is distributed along with this
// software and can be found at http://www.gnu.org/licenses/lgpl.html
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
bundle: ['./src/index.ts', './src/app.scss'],
sw: ['./src/sw.ts']
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: 'tsconfig.json',
},
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
},
{
test: /\.(sass|css|scss)$/,
use: [
/*{
loader: 'file-loader',
options: {
name: 'bundle.css',
},
},
{ loader: 'extract-loader' }, */
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'resolve-url-loader'},
{
loader: 'sass-loader',
options: {
// Prefer Dart Sass
implementation: require('sass'),
// See https://github.com/webpack-contrib/sass-loader/issues/804
webpackImporter: false,
sassOptions: {
includePaths: ['node_modules'],
},
sourceMap: true
},
},
],
},
],
},
resolve: {
extensions: ['.ts', '.js', '.css', '.scss'],
alias: {
'@src': path.resolve('./src'),
'@components': path.resolve('./src/components'),
'@store': path.resolve('./src/store'),
},
},
output: {
filename: '[name].js',
publicPath: '/',
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
new webpack.DefinePlugin({
'API_URL': JSON.stringify('/api/')
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'src/img/icon.png', to: 'img/icon.png' },
{ from: 'src/manifest.webmanifest', to: 'manifest.webmanifest' },
],
options: {
concurrency: 100,
},
})
],
};