-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
51 lines (51 loc) · 1.27 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
// 這邊使用 HtmlWebpackPlugin,將 bundle 好的 <script> 插入到 body。${__dirname} 為 ES6 語法對應到 __dirname
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: `./public/index.html`,
filename: 'index.html',
inject: 'body',
});
const path = require('path');
module.exports = {
performance: {
hints: false
},
// 檔案起始點從 entry 進入,因為是陣列所以也可以是多個檔案
entry: [
'./src/index.js',
],
// output 是放入產生出來的結果的相關參數
output: {
path: `${__dirname}/`,
filename: 'index_bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader?sourceMap!sass-loader?sourceMap'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.json$/,
loader: 'json-loader',
type: "javascript/auto"
}
],
},
// devServer 則是 webpack-dev-server 設定
devServer: {
inline: true,
port: 8008,
},
// plugins 放置所使用的外掛
plugins: [HTMLWebpackPluginConfig],
};