-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (81 loc) · 1.95 KB
/
webpack.config.js
File metadata and controls
83 lines (81 loc) · 1.95 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
'use strict';
const ip = require('ip');
const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
const isProd = process.env.NODE_ENV != 'development';
module.exports = {
context: __dirname,
devtool: isProd ? 'cheap-module-source-map':'source-map', //cheap-module-eval-source-map
// devtool: false,
entry: {
'demo/index': './demo/index.js',
},
output: {
path: path.join(__dirname, '/dist'),
publicPath: '/dist/',
filename: '[name].js',
libraryTarget: 'umd',
library: pkg.name,
libraryExport: 'default',
umdNamedDefine: true,
},
stats: {
modules: false,
},
module: {
rules: [
{
test: /\.js/,
exclude: /node_modules|assembly/,
enforce: 'pre',
use: 'eslint-loader',
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-transform-runtime', {
// 开启后,关闭commonjs方式,以esm方式引入helpers函数
// useESModules: true, //默认false
}],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties'
],
},
},
],
}
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
watchOptions: {
ignored: /node_modules/,
// poll: 1000
},
devServer: {
//允许手机绑定本地代理服务后访问,
host: `${ip.address()}`,
contentBase: [
'dist',
'demo',
],
hot: true
},
resolve: {
extensions: ['.js', '.ts'],
modules: ['node_modules'],
mainFields:['module', 'main'],
alias: {
'js-utils-url': path.resolve('./src/index')
}
}
};