-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathwebpack.config.js
95 lines (92 loc) · 2.64 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
require('dotenv').config()
const webpack = require('webpack')
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = env => {
let config = {
mode: 'development',
entry: './src/main.js',
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '/build/',
filename: 'bundle.js'
},
devtool: 'inline-source-map',
devServer: {
historyApiFallback: true
},
plugins: [
new VueLoaderPlugin(),
new webpack.DefinePlugin({
'process.env.YOUTUBE_API_KEY': `"${process.env.YOUTUBE_API_KEY}"`
})
],
resolve: {
alias: {
'~': path.resolve(__dirname, 'src/'),
'~api': path.resolve(__dirname, 'src/api/'),
'~assets': path.resolve(__dirname, 'src/assets/'),
'~components': path.resolve(__dirname, 'src/components/'),
'~config': path.resolve(__dirname, 'src/weblearn.config.js'),
'~events': path.resolve(__dirname, 'src/events/'),
'~pages': path.resolve(__dirname, 'src/pages/'),
'~store': path.resolve(__dirname, 'src/store/'),
'~topics': path.resolve(__dirname, 'src/topics/'),
'~transformers': path.resolve(__dirname, 'src/transformers/'),
'~util': path.resolve(__dirname, 'src/util/'),
'~widgets': path.resolve(__dirname, 'src/widgets/')
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
scss: 'vue-style-loader!css-loader!sass-loader'
}
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(yml|yaml)$/,
loader: 'json-loader!yaml-loader'
},
{
test: /\.pug$/,
loader: 'pug-plain-loader'
},
{
test: /\.sass$/,
loader: 'style-loader!css-loader!sass-loader?indentedSyntax'
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
}
]
}
}
if (env && env.analyze) {
config.plugins = (config.plugins || []).concat([new BundleAnalyzerPlugin()])
}
return config
}