forked from Vanessa219/vditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.start.js
149 lines (146 loc) · 3.55 KB
/
webpack.start.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**
* @fileoverview demo.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 0.3.0.0, Sep 3, 2019
*/
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const pkg = require('./package.json')
module.exports = {
mode: 'development',
output: {
filename: '[name]',
path: path.resolve(__dirname, 'demo/dist'),
},
entry: {
'index.js': './demo/index.js',
'render.js': './demo/render.js',
'jest-puppeteer.js': './demo/jest-puppeteer.js',
'comment.js': './demo/comment.js',
},
resolve: {
extensions: ['.js', '.ts', '.png', '.less'],
},
module: {
rules: [
{
test: /\.less$/,
include: [path.resolve(__dirname, 'src')],
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader', // translates CSS into CommonJS
options: {
url: false,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
['autoprefixer', {grid: true, remove: false}],
],
},
},
},
{
loader: 'less-loader', // compiles Less to CSS
},
],
},
{
test: /\.ts$/,
use: 'ts-loader',
},
{
test: /\.js$/,
exclude: '/node_modules/',
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/env',
{
targets: {
browsers: [
'last 2 Chrome major versions',
'last 2 Firefox major versions',
'last 2 Safari major versions',
'last 2 Edge major versions',
'last 2 iOS major versions',
'last 2 ChromeAndroid major versions',
],
},
},
],
],
},
},
},
{
test: /\.png$/,
include: [path.resolve(__dirname, './src/assets/images')],
use: [
'file-loader',
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
chunks: ['index.js'],
filename: './index.html',
template: './demo/index.html',
}),
new HtmlWebpackPlugin({
chunks: ['render.js'],
filename: './render.html',
template: './demo/render.html',
}),
new HtmlWebpackPlugin({
chunks: ['jest-puppeteer.js'],
filename: './jest-puppeteer.html',
template: './demo/jest-puppeteer.html',
}),
new HtmlWebpackPlugin({
chunks: ['comment.js'],
filename: './comment.html',
template: './demo/comment.html',
}),
new webpack.DefinePlugin({
VDITOR_VERSION: JSON.stringify(pkg.version),
}),
new CopyPlugin({
patterns: [
{from: 'src/css', to: 'css'},
{from: 'src/images', to: 'images'},
{from: 'src/js', to: 'js'},
{from: 'types', to: 'types'},
],
}),
],
devServer: {
static: {
directory: path.join(__dirname, '.'),
},
port: 9000,
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://localhost:8080',
pathRewrite: {'^/api': ''},
},
'/ld246': {
target: 'https://ld246.com',
pathRewrite: {'^/ld246': ''},
},
},
},
}