-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
112 lines (109 loc) · 3.25 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 webpack = require('webpack');
const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require('path');
// i can see the list of plugins I am using
const htmlPlugin = new HtmlWebPackPlugin({
template: "./src/template/index.html",
filename: "index.html" // The filename value is the name of the minified HTML that will be generated in the dist folder.
});
const hmrPlugin = new webpack.HotModuleReplacementPlugin();
module.exports = {
entry: {
main: "./src/app.js"
},
output: {
path: path.resolve(__dirname, 'docs'),
filename: "[name]-[hash].js"
},
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300, // The default
poll: 1000 // Check for changes every seconds
},
devServer: {
contentBase: path.resolve(__dirname, 'docs'),/* By default it will use your current working directory to serve content. To disable contentBase set it to false */
//contentBase:[__dirname, path.join(__dirname, 'assets')], /* serve from multiple directories */
publicPath:"./",
compress: true /* Enable gzip compression for everything served */,
//historyApiFallback: true,
//hotOnly: true, /* Enables Hot Module Replacement (see devServer.hot) without page refresh as fallback in case of build failures. */
inline: true,
// port: 9091, /* default is 8080 */
progress: true,
/*proxy: {
'/api': 'http://localhost:3000' /* Proxying some URLs can be useful when you have a separate API backend development server and you want to send API requests on the same domain. */
/*},*/
// stats: {
// cached: false
// }
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "eslint-loader"
}
},
{
test: /\.css$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 1,
localIdentName: "[name]_[local]_[hash:base64]",
sourceMap: true,
minimize: true
}
}
]
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"]
},
// { //it returns a DataURL if the file is < 10000 bytes
// test: /\.(jp(e*)g|png)$/,
// use: {
// loader: 'url-loader',
// options: {
// limit: 8000, // Convert images < 8kb to base64 strings
// name: '[name].[ext]',
// //publicPath: 'images',
// },
// },
// },
{
test: /\.(jp(e*)g|png)$/,
use: {
loader: "file-loader",
options: {
name: '[path][name]-[hash:8].[ext]', // réplique le chemin dans le repertoire de sortie
// outputPath: 'images', si on veut un répertoire différent dans le repertoire de sortie
}
}
}
]
},
plugins: [htmlPlugin/*, hmrPlugin*/]
/* or
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
})
] */
};