forked from javaLuo/vue-puzzle-vcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.production.config.js
68 lines (66 loc) · 2.08 KB
/
webpack.production.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
61
62
63
64
65
66
67
68
/** 这是用于开发环境的webpack配置文件 **/
const path = require('path'); // 获取绝对路径用
const webpack = require('webpack'); // webpack核心
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); // 每次打包前清除旧的build文件夹
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
mode: 'production',
entry: './src/index.js', // 项目入口
output: {
path: path.resolve(__dirname, './dist'), // 将打包好的文件放在此路径下,dev模式中,只会在内存中存在,不会真正的打包到此路径
filename: '[name].js', //编译后的文件名字
publicPath: '/dist/',
library: 'vue-puzzle-vcode',
libraryTarget: 'umd',
// umdNamedDefine: true,
},
externals: {
vue: 'vue',
},
module: {
rules: [
{
test: /\.vue$/,
use: ['vue-loader'],
include: path.resolve(__dirname, 'src'),
},
{
// .js .jsx用babel解析
test: /\.(js|jsx)?$/,
use: ['babel-loader'],
include: path.resolve(__dirname, 'src'),
},
{
// .css 解析
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
include: path.resolve(__dirname, 'src'),
},
{
// .less 解析
test: /\.less$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'],
include: path.resolve(__dirname, 'src'),
},
{
// 文件解析
test: /\.(eot|woff|otf|svg|ttf|woff2|appcache|mp3|mp4|pdf)(\?|$)/,
include: path.resolve(__dirname, 'src'),
use: ['file-loader?name=assets/[name].[ext]'],
},
{
// 图片解析
test: /\.(png|jpg|gif|svg)(\?|$)/,
include: path.resolve(__dirname, 'src'),
use: ['url-loader?limit=8192&name=assets/[name].[ext]'],
},
],
},
plugins: [new VueLoaderPlugin(), new CleanWebpackPlugin()],
resolve: {
extensions: ['.js', '.vue', '.less', '.css'], //后缀名自动补全
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
};