-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
74 lines (65 loc) · 1.76 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = (env, argv) => {
const isDev = argv.$0.endsWith('webpack-dev-server.js');
// eslint-disable-next-line no-console
console.log("MODE DEV : " + isDev);
return {
devServer: {
contentBase: path.join(__dirname, 'frontdist'),
compress: true,
port: 9000,
},
mode: isDev ? 'development' : 'production',
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
entry: './frontsrc/index.tsx',
output: {
path: path.resolve(__dirname, 'frontdist'),
filename: 'main.js',
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", '.js', '.jsx'],
},
plugins: [
new HtmlWebpackPlugin({
title: "Ptite coinche",
template: './index.html',
}),
new CopyPlugin([
{ from: './node_modules/react/umd/react.' + (isDev ? 'development' : 'production.min') + '.js', to: 'react.js' },
{ from: './node_modules/react-dom/umd/react-dom.' + (isDev ? 'development' : 'production.min') + '.js', to: 'react-dom.js' },
{ from: './cards/*.png', to: '[name].[ext]' },
]),
],
module: {
rules: [
{
test: /\.ts(x?)$/u,
exclude: /node_modules/u,
use: [
{
loader: "ts-loader",
options: {
configFile: '../tsconfigFront.json',
},
},
],
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/u,
loader: "source-map-loader",
},
],
},
// Importés directement pour éviter d'allourdir la compilation
externals: {
"react": "React",
"react-dom": "ReactDOM",
},
};
};