forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.base.conf.js
93 lines (92 loc) · 3.14 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
88
89
90
91
92
93
const webpack = require('webpack');
const config = require('../package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const moment = require('moment');
const isDev = process.env.NODE_ENV === 'development';
var test = process.env.NODE_ENV === 'test';
const path = require('path');
module.exports = {
stats: {
entrypoints: false,
children: false
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
}
},
module: {
rules: [
test ? {
test: /\.(js|ts)/,
include: path.resolve('src'), // instrument only testing sources with Istanbul, after ts-loader runs
loader: 'istanbul-instrumenter-loader'
}: {},
test ? { test: /\.css$/, use: [{loader: 'style!css'}] } : {},
test ? { test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader' } : {},
test ? { test: /\.scss$/, use: [{loader: 'sass-loader', options:{data: `@import "./src/styles/index.scss"; `,} }]} : {},
!test ?{
test: /\.(sa|sc|c)ss$/,
use: [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
data: `@import "./src/styles/index.scss"; `,
},
}
],
}:{},
{
test: /\.svg$/,
use: 'raw-loader'
},
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
/* preLoaders: {
js: 'istanbul-instrumenter-loader?esModules=true'
}, */
loaders: {
sass: [isDev ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader', 'postcss-loader']
}
}
}
]
},
{
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.(png|jpg|gif|webp)$/,
loader: 'url-loader',
options: {
limit: 3000,
name: 'img/[name].[ext]',
}
},]
},
plugins: [
new webpack.BannerPlugin({
banner: "NutUI2(" + config.version + ") - [filebase], [hash], " + moment().format()
}),
new VueLoaderPlugin()
],
}