forked from FrankerFaceZ/FrankerFaceZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
143 lines (138 loc) · 2.82 KB
/
webpack.common.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
const webpack = require('webpack');
const path = require('path');
const semver = require('semver');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
/* global process module __dirname */
const VERSION = semver.parse(require('./package.json').version);
const PRODUCTION = process.env.NODE_ENV === 'production';
const ENTRY_POINTS = {
bridge: './src/bridge.js',
player: './src/player.js',
avalon: './src/main.js',
clips: './src/clips.js'
};
module.exports = {
entry: ENTRY_POINTS,
resolve: {
extensions: ['.js', '.jsx'],
alias: {
res: path.resolve(__dirname, 'res/'),
styles: path.resolve(__dirname, 'styles/'),
root: __dirname,
src: path.resolve(__dirname, 'src/'),
utilities: path.resolve(__dirname, 'src/utilities/')
}
},
externals: [
function(context, request, callback) {
if ( request === 'vue' && ! /utilities/.test(context) )
return callback(null, 'root ffzVue');
callback();
}
],
output: {
chunkFilename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
jsonpFunction: 'ffzWebpackJsonp',
crossOriginLoading: 'anonymous'
},
optimization: {
splitChunks: {
chunks(chunk) {
return ! Object.keys(ENTRY_POINTS).includes(chunk.name);
},
cacheGroups: {
vendors: false
}
}
},
plugins: [
new VueLoaderPlugin(),
new webpack.ExtendedAPIPlugin(),
new webpack.DefinePlugin({
__version_major__: VERSION.major,
__version_minor__: VERSION.minor,
__version_patch__: VERSION.patch,
__version_prerelease__: VERSION.prerelease
}),
],
module: {
rules: [{
test: /\.s?css$/,
use: [{
loader: 'file-loader',
options: {
name: PRODUCTION ? '[name].[hash].css' : '[name].css'
}
}, {
loader: 'extract-loader'
}, {
loader: 'css-loader',
options: {
sourceMap: true
}
}, {
loader: 'sass-loader',
options: {
sourceMap: true
}
}]
},
{
test: /\.json$/,
include: /src/,
type: 'javascript/auto',
loader: 'file-loader',
options: {
name: PRODUCTION ? '[name].[hash].json' : '[name].json'
}
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true
}
},
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
plugins: [
['@babel/plugin-transform-react-jsx', {
pragma: 'createElement'
}]
]
}
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
},
{
test: /\.(?:eot|ttf|woff|woff2)$/,
use: [{
loader: 'file-loader',
options: {
name: PRODUCTION ? '[name].[hash].[ext]' : '[name].[ext]'
}
}]
},
{
test: /\.md$/,
loader: 'raw-loader'
},
{
test: /\.svg$/,
loader: 'raw-loader'
},
{
test: /\.vue$/,
loader: 'vue-loader'
}]
}
}