-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
71 lines (68 loc) · 2.23 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
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cdnDev = require("./cdn.dev")
// Get variable ENV, prod or dev
const env = process.env.NODE_ENV
const isAnalyze = !!process.env.ANALYSE
const analyzerMode = isAnalyze ? "server" : "disabled"
const config = {
// Webpack start from this entry point
entry: {
myApp: [
"./src/index.ts",
],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
// Allow to tell to ts-loader: "If you see .vue file, handle it as a .ts"
appendTsSuffixTo: [/\.vue$/]
}
}, {
test: /\.vue$/,
loader: "vue-loader",
}, {
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'url-loader'
},
],
},
// External lib that will not be put in bundle but use from CDN
externals: {
vue: 'Vue',
},
// The resolve object allows you to configure how webpack’s module resolution works
resolve: {
// Attempt to resolve these extensions in order
extensions: ['.ts', '.js', '.vue'],
// Just alias
alias: {
'vue$': 'vue/dist/vue.esm.js',
}
},
plugins: [
// vue-loader is a loader for webpack that allows you to author Vue components in a format called Single-File Components
new VueLoaderPlugin(),
new BundleAnalyzerPlugin({
openAnalyzer: isAnalyze,
analyzerMode,
}),
// Need to be use in dev also since dev need an HTML page for working!
new HtmlWebpackPlugin({
title: 'Youtube Downloader',
template: './src/index.html',
cdn: cdnDev,
inject: true,
minify: {
removeComments: true,
collapseWhitespace: false
}
})
],
}
module.exports = config