-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack-dev.config.js
120 lines (114 loc) · 2.93 KB
/
webpack-dev.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const path = require('path');
const join = path.join;
const resolve = path.resolve;
const {camelCase} = require('lodash');
const webpack = require('webpack');
// const {TsConfigPathsPlugin} = require('awesome-typescript-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const env = process && process.env && process.env.NODE_ENV;
const serverPort = process.env.npm_package_config_devPort || 8081;
const libraryName = 'webgl';
const VueLoaderPlugin = require('vue-loader/lib/plugin');
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
index: './examples-webgl/index.ts',
},
devtool: 'none',
output: {
path: join(__dirname, 'dist'),
libraryTarget: 'umd',
library: camelCase(libraryName),
filename: `${libraryName}.js`,
globalObject: 'this',
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/], // vue 单文件写法
},
},
],
exclude: /node_modules/,
},
{
test: /\-worker\.ts$/,
use: [
{
loader: 'worker-loader',
options: {
inline: true,
publicPath: '/src/websocket/',
},
},
],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
esModule: false, // 这里设置为false,否则webpack打包img后src为“[object Module]”
name: './images/[name].[ext]',
// limit: 8192
},
},
],
},
plugins: [
// new TsConfigPathsPlugin({
// configFile: path.resolve(__dirname, '../tsconfig.json')
// }),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
inject: true,
title: libraryName,
favicon: join(__dirname, 'assets/images/logo.png'),
filename: 'index.html',
template: join(__dirname, 'examples-webgl/index.html'),
hash: true,
chunks: ['index'], // 和entry相对应
}),
],
resolve: {
extensions: ['.js', '.vue', '.json', '.ts'],
alias: {
vue$: 'vue/dist/vue',
'@': path.resolve(__dirname, './examples-webgl'),
src: path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, './'),
// common: resolve('src/common'),
// components: resolve('src/components')
},
plugins: [
// new TsConfigPathsPlugin({
// configFile: 'tsconfig.json'
// })
],
},
devServer: {
hot: true,
contentBase: resolve(__dirname),
port: serverPort,
publicPath: '/',
},
// node: {
// fs:'empty'
// }
};