-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathwebpack.dev.config.js
60 lines (60 loc) · 1.75 KB
/
webpack.dev.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
var path = require("path");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const PUBLIC_PATH = "/";
module.exports = {
mode: "development",
entry: [path.join(__dirname, "example", "main.js")],
output: {
filename: "bundle.js",
publicPath: PUBLIC_PATH,
},
module: {
rules: [
{
test: /.vue$/,
use: ["vue-loader"],
include: [path.join(__dirname, "example"), path.join(__dirname, "src")],
},
{
test: /\.js$/,
use: ["babel-loader"],
include: [path.join(__dirname, "example"), path.join(__dirname, "src")],
},
{
// .css 解析
test: /\.css$/,
use: ["style-loader", "css-loader", "postcss-loader"],
include: [path.join(__dirname, "example"), path.join(__dirname, "src")],
},
{
// .less 解析
test: /\.less$/,
use: ["style-loader", "css-loader", "postcss-loader", "less-loader"],
include: [path.join(__dirname, "example"), path.join(__dirname, "src")],
},
{
// 文件解析
test: /\.(eot|woff|otf|svg|ttf|woff2|appcache|mp3|mp4|pdf)(\?|$)/,
include: [path.resolve(__dirname, "example"), path.join(__dirname, "src")],
use: ["file-loader?name=assets/[name].[ext]"],
},
{
// 图片解析
test: /\.(png|jpg|jpeg|gif)(\?|$)/,
include: [path.resolve(__dirname, "example"), path.join(__dirname, "src")],
use: ["url-loader?limit=8192&name=assets/[name].[ext]"],
},
],
},
devServer: {
static: {
directory: path.join(__dirname, 'example'),
},
hot: true,
open: true,
},
plugins: [new VueLoaderPlugin()],
resolve: {
extensions: [".js", ".vue", ".less", ".css"], //后缀名自动补全
},
};