-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
99 lines (98 loc) · 3.1 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const Dotenv = require('dotenv-webpack');
module.exports = {
entry: './src/index.ts',
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-proposal-object-rest-spread'],
},
},
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{loader: 'url-loader', test: /\.gif$/},
{loader: 'file-loader', test: /\.(ttf|eot|svg)$/},
{
test: /\.s[ac]ss$/i,
include: /\.component\.scss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[hash:base64:7]',
// namedExport: true,
exportOnlyLocals: false,
},
importLoaders: true,
esModule: true,
},
},
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.pug$/i,
loader: '@webdiscus/pug-loader',
options: {
method: 'render',
}
},
{
test: /\.s[ac]ss$/i,
exclude: /\.component\.scss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
{
loader: 'css-loader',
},
// Compiles Sass to CSS
'sass-loader',
],
},
],
},
plugins: [
new Dotenv(),
new HtmlWebpackPlugin({
template: './src/views/index.pug',
}),
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()],
},
output: {
filename: 'bundle.[contenthash].js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 8000,
},
};