forked from baptiste-roullin/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
132 lines (120 loc) · 3.46 KB
/
webpack.config.js
File metadata and controls
132 lines (120 loc) · 3.46 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const path = require('path')
const CopyPlugin = require("copy-webpack-plugin");
const WebpackAssetsManifest = require('webpack-assets-manifest');
require('dotenv').config()
const meta = require('./src/_data/meta.js')
module.exports = {
devServer: {
stats: {
colors: true,
hash: false,
version: false,
timings: false,
assets: false,
chunks: false,
modules: false,
reasons: false,
children: false,
source: false,
errors: true,
errorDetails: false,
warnings: true,
publicPath: false
}
},
resolve: {
extensions: ['.ts', '.js'],
},
entry: {
search: path.resolve(__dirname, 'src/assets/scripts/search.js'),
contact: path.resolve(__dirname, 'src/assets/scripts/contact.js'),
main: path.resolve(__dirname, 'src/assets/scripts/main.js'),
richPicture: path.resolve(__dirname, 'src/assets/scripts/richPicture.ts'),
spin: path.resolve(__dirname, 'src/assets/scripts/spin.ts'),
nav: path.resolve(__dirname, 'src/assets/scripts/nav.ts'),
arrowPagination: path.resolve(__dirname, 'src/assets/scripts/arrowPagination.ts'),
truchet: path.resolve(__dirname, 'src/features/truchet/truchet-core.ts'),
'truchet-dom': path.resolve(__dirname, 'src/features/truchet/truchet-dom.ts'),
},
output: {
path: path.resolve(__dirname, meta.outputDir + '/assets/scripts'),
/* détournement du publicpatch*/
//publicPath: path.resolve(__dirname, 'src'),
filename: () => (process.env.NODE_ENV === "production" ? '[name].[contenthash].js' : '[name].js')
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: "tsconfig.front.json",
transpileOnly: true
}
},
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.njk$/,
use: [
{
loader: 'simple-nunjucks-loader',
options: {
searchPaths: [
'src/_templates/components',
'src/_templates/utils'
], filters: {
dateHumanFormat: path.resolve('src/filters/dateFormatting.js'),
removeMD: path.resolve('src/filters/removeMD.js')
}
}
}
]
},
],
},
plugins: [
new WebpackAssetsManifest({
output: '../../../src/_data/hashes_js.json'
}),
new CopyPlugin({
patterns: [
//On copie média avec chemins relatifs ou absolus dans un dossier unique intermédiaire, que les scripts puissent processer
{
from: "posts/**/*.{png,webp,gif,mp4,jpg,jpeg}",
context: "src",
to({ context, absoluteFilename }) {
return `${context}/assets/imagesToProcess/[name][ext]`;
},
},
{
from: "assets/images/*",
context: "src",
to({ context, absoluteFilename }) {
return `${context}/assets/imagesToProcess/[name][ext]`;
},
},
{
from: "assets/UI/*",
context: "src",
to({ context, absoluteFilename }) {
return `${context}/assets/imagesToProcess/[name][ext]`;
},
},
],
options: {
concurrency: 100,
},
})
],
}