-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
71 lines (67 loc) · 2.41 KB
/
Copy pathwebpack.config.js
File metadata and controls
71 lines (67 loc) · 2.41 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
var path = require('path');
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
module.exports = {
entry: path.resolve(APP_PATH, 'index.js'),
output: {
path: BUILD_PATH,
filename: 'bundle.js'
},
//babel重要的loader在这里
module: {
loaders: [
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
{
test: /\.(css|scss)$/,
loader: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
},
{
test: /\.jsx?$/,
loader: "babel-loader",
include: APP_PATH,
},
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// it's runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|jsx|mjs|less|scss|css)$/, /\.html$/, /\.json$/],
options: {
name: 'static/[name].[hash:8].[ext]',
},
},
]
},
devtool: 'eval-source-map', //开发环境
devServer: {
compress: true, // 启用Gzip压缩
historyApiFallback: true, // 为404页启用多个路径
hot: true, // 模块热更新,配置HotModuleReplacementPlugin
https: false, // 适用于ssl安全证书网站
noInfo: true, // 只在热加载错误和警告
// ...
},
plugins: [
new InterpolateHtmlPlugin({
PUBLIC_URL: '/public'
// You can pass any key-value pairs, this was just an example.
// WHATEVER: 42 will replace %WHATEVER% with 42 in index.html.
}),
new HtmlwebpackPlugin({
title: '',
template: 'public/index.html'
})
],
}