-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
97 lines (96 loc) · 2.71 KB
/
Copy pathwebpack.config.js
File metadata and controls
97 lines (96 loc) · 2.71 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
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
//const HtmlWebpackPlugin = require('html-webpack-plugin')
const config = {
//entry:[
// './src/main.js',
// './src/home.js'
//],
entry: {
main: './src/main.js',
generator: './src/pages/generator/index.js'
},
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
// filename: 'bundle.js'
filename: '[name].js'
},
resolve: {
alias: {
'@':path.resolve(__dirname,'./src'),
'assets':path.resolve(__dirname,'./src/assets'),
'pages':path.resolve(__dirname,'./src/pages'),
'router':path.resolve(__dirname,'./src/router'),
'css':path.resolve(__dirname,'./src/css'),
'components':path.resolve(__dirname,'./src/components'),
'mixins':path.resolve(__dirname,'./src/mixins'),
'utils':path.resolve(__dirname,'./src/utils'),
'config':path.resolve(__dirname,'./src/config')
},
extensions: ['*', '.js', '.vue', '.json', ',css', '.scss']
},
devServer: {
port: 8088,
noInfo: true, // 当前环境 下未生效 node v10.5.0 webpack 4.17.0 webpack-dev-server 3.1.0
historyApiFallback: true, // 任何404 返回index.html
compress: true, // gzip压缩
quiet: false, // 隐藏控制台
// overlay: {
// warnings: true,
// errors: true
// }
},
performance: {
hints: false
},
module: {
rules: [{
test: /\.vue$/,
use: 'vue-loader'
},{
test: /\.css$/,
use: ['vue-style-loader','css-loader']
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // 将 JS 字符串生成为 style 节点
}, {
loader: "css-loader" // 将 CSS 转化成 CommonJS 模块
}, {
loader: "sass-loader"// 你也可以从一个文件读取,例如 `variables.scss`
},{
loader: "sass-resources-loader",
options: {
// 多个文件时用数组的形式传入,单个文件时可以直接使用 path.resolve(__dirname, '../static/style/common.scss'
resources: path.resolve(__dirname, './src/css/variable.scss')
}
}]
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(eot|woff|woff2|ttf)([\\?]?.*)$/,
loader: "file-loader"
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}]
},
devtool: 'eval-source-map', // 控制台显示文件
plugins: [
new VueLoaderPlugin(),
// new BundleAnalyzerPlugin()
// new HtmlWebpackPlugin()
]
}
module.exports = config