-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
88 lines (85 loc) · 2.5 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
// PLUGINS
const { DefinePlugin } = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin');
const cssToFile = require('mini-css-extract-plugin');
// PATHES
const path = require('path');
const publicPath = path.join(__dirname, 'public/assets');
// DOTENV
const dotenv = require('dotenv').config();
module.exports = {
entry: [
'./resources/scripts/main.ts',
'./resources/styles/main.scss'
],
output: {
path: publicPath,
filename: '[name].[contenthash].js',
publicPath,
},
resolve: {
alias: {
fonts: path.join(__dirname, '/resources/fonts')
},
extensions: ['.ts', '.tsx', '.js', 'jsx'],
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'ts-loader',
options: {
configFile: path.join(__dirname, '/resources/tsconfig.json')
}
},
{
test: /\.(scss)$/,
use: [
// fallback to style-loader in development
cssToFile.loader,
'css-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.woff$/,
loader: 'file-loader',
options: {
publicPath: '/fonts/',
outputPath: 'fonts',
name: '[name].[hash:16].[ext]',
esModule: false,
},
},
]
},
plugins: [
new DefinePlugin({
'process.env': JSON.stringify({
SERVER_BASE: dotenv.parsed.SERVER_BASE,
BUSINESS_INSTAGRAM: dotenv.parsed.BUSINESS_INSTAGRAM,
}),
}),
new WebpackManifestPlugin({
basePath: 'assets/',
publicPath: 'assets/',
}),
new CopyPlugin({
patterns: [{
from: 'resources/images',
to: '[path][name].[contenthash][ext]',
globOptions: {
ignore: ['**/.DS_Store'],
},
}]
}),
new CleanWebpackPlugin(),
new cssToFile({
filename: '[name].[contenthash].css'
}),
],
};