-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
90 lines (88 loc) 路 2.04 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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const pkg = require(path.join(process.cwd(), 'package.json'));
const pkgKey = pkg.name.replace('@turbox3d/', '');
function toCamelCase(str) {
const lowerStr = str.toLowerCase();
const firstUpperStr = lowerStr.substr(0, 1).toUpperCase() + lowerStr.substr(1);
return firstUpperStr.replace(/-(.)/g, function (match, group1) {
return group1.toUpperCase();
});
}
module.exports = {
entry: ['./es/index.js'],
output: {
path: path.resolve(process.cwd(), './dist'),
filename: `index${process.env.NODE_ENV === 'production' ? '.min' : ''}.js`,
library: {
commonjs: pkg.name,
amd: pkg.name,
root: toCamelCase(pkgKey),
},
libraryTarget: 'umd'
},
externals: {
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
root: 'ReactDOM'
},
'pixi.js': {
commonjs: 'pixi.js',
commonjs2: 'pixi.js',
amd: 'pixi.js',
root: 'PIXI'
},
three: {
commonjs: 'THREE',
commonjs2: 'THREE',
amd: 'THREE',
root: 'THREE',
},
},
module: {
rules: [{
test: /\.less$/,
use: [{
loader: MiniCssExtractPlugin.loader,
}, {
loader: 'css-loader',
}, {
loader: 'postcss-loader',
options: {
postcssOptions: {
parser: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
require('autoprefixer')({
flexbox: 'no-2009',
}),
],
}
}
}, {
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
}
}
}]
}]
},
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx']
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
};