-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathwebpack.base.conf.js
87 lines (82 loc) · 1.93 KB
/
webpack.base.conf.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const utils = require('./utils');
const config = require('../config');
function resolve(dir) {
return path.join(__dirname, '..', dir);
}
const isProd = process.env.NODE_ENV === 'production';
const styleLoader = isProd ? MiniCssExtractPlugin.loader : 'vue-style-loader';
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: !isProd,
esModule: false,
},
};
module.exports = {
entry: {
app: './example/main.js',
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: isProd ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.json'],
alias: {
src: resolve('src'),
},
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.[t|j]s[x]?$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('example'), resolve('test')],
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]'),
},
},
{
test: /\.css$/,
use: [styleLoader, cssLoader],
},
{
test: /\.less$/,
use: [
styleLoader,
cssLoader,
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
},
],
},
plugins: [
new ESLintPlugin({
extensions: ['js', 'jsx', 'ts', 'tsx', 'vue'],
emitError: true,
emitWarning: true,
}),
new VueLoaderPlugin(),
],
};