-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
115 lines (111 loc) · 3.14 KB
/
Copy pathwebpack.config.js
File metadata and controls
115 lines (111 loc) · 3.14 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
/**
* Created by Administrator on 2018/6/16/016.
*/
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
mode:'development',
entry: {
app: './src/js/index.js',
},
output: {
// publicPath: './',
filename: "[name].bundle.js",
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/,
// exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
// presets: ['env']
presets: ['env']
}
}
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // 将 JS 字符串生成为 style 节点
}, {
loader: "css-loader" // 将 CSS 转化成 CommonJS 模块
}, {
loader: "sass-loader" // 将 Sass 编译成 CSS
}]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /.(png|jpg|gif|svg)/,
use: [{
loader: "url-loader",
options: {
limit: 1024,
outputPath: 'imgs/'
}
}]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [{
loader: "url-loader",
options: {
limit: 8,
outputPath: 'font/'
}
}]
},
{
test: /\.html$/,
use: ['html-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: '天猫',
template: './src/index.html'
}),
new CleanWebpackPlugin(['dist']),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([{
from: path.resolve(__dirname, 'src/plugins/layui'),
to:path.resolve(__dirname,"dist")
},
{
from: path.resolve(__dirname, 'src/imgs'),
to:path.resolve(__dirname,"dist/imgs")
},
{
from: path.resolve(__dirname, 'src/font'),
to:path.resolve(__dirname,"dist/font")
},
]),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
],
devtool: 'eval',
// devtool:'inline-source-map',
devServer: {
contentBase: './dist',
// hot:true,
host: '192.168.1.15',
inline: true,
port: 8047,
}
};