forked from alibaba/x-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·104 lines (103 loc) · 2.52 KB
/
webpack.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
const { resolve } = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
mode: 'development',
context: resolve(__dirname, 'demo'),
entry: './index.js',
output: {
filename: '[name].bundle.js',
path: resolve(__dirname, 'docs/demo'),
},
module: {
rules: [
{
test: /\.jsx?$/,
use: ['babel-loader'],
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
},
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new MonacoWebpackPlugin({
languages: ['json'],
features: ['snippets', 'suggest'],
}),
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
new HtmlWebpackPlugin({
resources: {
js: [
'[email protected]/umd/react.development.js',
'[email protected]/umd/react-dom.development.js',
'[email protected]/prop-types.min.js',
'[email protected]/min/moment.min.js',
'@alifd/[email protected]/dist/next.min.js',
],
css: ['@alifd/[email protected]/dist/next.min.css'],
},
excludeChunks: ['main'],
template: resolve(__dirname, 'demo/index.html'),
}),
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false,
extractComments: false,
uglifyOptions: {
compress: {
unused: true,
drop_debugger: true,
},
warnings: false,
output: {
comments: false,
},
},
}),
],
externals: {
react: 'var window.React',
'react-dom': 'var window.ReactDOM',
'prop-types': 'var (window.PropTypes || window.React.PropTypes)',
'@alifd/next': 'var window.Next',
},
watchOptions: {
ignored: /node_modules/,
},
devServer: {
contentBase: resolve(__dirname, 'docs/demo'),
publicPath: '/',
port: 9000,
host: '127.0.0.1',
watchContentBase: true,
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'monaco-editor': 'monaco-editor/esm/vs/editor/editor.api',
},
},
};