-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
112 lines (109 loc) · 3.61 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
100
101
102
103
104
105
106
107
108
109
110
111
112
const path = require('path');
var mainPath = path.resolve(__dirname, 'src', 'index.tsx');
var autoprefixer = require('autoprefixer');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt');
var Dotenv = require('dotenv-webpack');
module.exports = {
entry: mainPath,
output: {
filename: 'bundle.js',
publicPath: 'http://localhost:9090/assets/',
path: path.resolve(__dirname, 'build'),
},
mode: 'development',
resolve: {
extensions: ['.js', '.json', '.ts', '.tsx'],
alias: {
react: path.join(__dirname, 'node_modules', 'react'),
},
},
module: {
rules: [
{ parser: { requireEnsure: false } },
// First, run the linter.
// It's important to do this before Babel processes the JS.
{
test: /\.(js|mjs|jsx)$/,
enforce: 'pre',
use: [
{
options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
},
loader: require.resolve('eslint-loader'),
},
],
},
{
test: /\.(ts|tsx)$/,
loader: 'awesome-typescript-loader'
},
{
test: /\.(js|mjs|jsx)$/,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve(
'babel-preset-react-app/webpack-overrides'
),
plugins: [
[
require.resolve('babel-plugin-named-asset-import'),
{
loaderMap: {
svg: {
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]',
},
},
},
],
],
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
// Don't waste time on Gzipping the cache
cacheCompression: false,
},
},
{
test: /\.less$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}, {
loader: 'postcss-loader',
options: {
plugins: function() {
return [autoprefixer];
},
},
}, {
loader: 'less-loader',
options: {
globalVars: {
nodeModulesPath: '~',
coreModulePath: '~',
},
},
}],
},
{
test: /\.((woff2?|svg)(\?v=[0-9]\.[0-9]\.[0-9]))|(woff2?|svg|jpe?g|png|gif|ico)$/,
use: [{
loader: 'svg-url-loader',
}],
},
]
},
plugins: [
new Dotenv(),
new ForkTsCheckerWebpackPlugin({
async: false,
watch: './src',
tsconfig: './tsconfig.json',
tslint: './tslint.json',
}),
]
};