forked from renanbrando/frontend-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
122 lines (118 loc) · 3.29 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* eslint-disable */
var webpack = require('webpack');
var path = require('path');
var VueLoaderPlugin = require('vue-loader/lib/plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
require('dotenv').config();
function isProduction() {
return process.env.NODE_ENV === 'production';
}
module.exports = {
mode: process.env.NODE_ENV,
watch: !isProduction(),
watchOptions: {
aggregateTimeout: 500,
ignored: ['node_modules']
},
resolve: {
alias: {
Router: path.resolve(__dirname, 'src', 'router'),
Store: path.resolve(__dirname, 'src', 'store'),
Pages: path.resolve(__dirname, 'src', 'pages'),
Components: path.resolve(__dirname, 'src', 'components'),
UI: path.resolve(__dirname, 'src', 'ui'),
Utils: path.resolve(__dirname, 'src', 'utils'),
Directives: path.resolve(__dirname, 'src', 'directives'),
Filters: path.resolve(__dirname, 'src', 'filters'),
Images: path.resolve(__dirname, 'src', 'images'),
Styles: path.resolve(__dirname, 'src', 'styles'),
Plugins: path.resolve(__dirname, 'src', 'plugins'),
Mixins: path.resolve(__dirname, 'src', 'mixins')
}
},
entry: path.resolve(__dirname, 'src', 'index.js'),
output: {
filename: isProduction() ? 'assets/main.[contenthash].js' : 'assets/main.js',
path: path.resolve(__dirname, 'build'),
publicPath: '/'
},
module: {
rules: [
{
enforce: 'pre',
test: /\.(js\vue)$/,
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
fix: false,
failOnWarning: true
}
},
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: function (file) {
return /node_modules/.test(file) && !/\.vue\.js/.test(file);
}
},
{
test: /\.s?css$/,
use: [
// consider vue-style-loader if not production?
// 'vue-style-loader',
MiniCssExtractPlugin.loader,
'css-loader',
// see postcss.config.js for options
'postcss-loader',
'sass-loader',
]
},
{
test: /\.pug$/,
oneOf: [
{
resourceQuery: /^\?vue/,
use: ['pug-plain-loader']
},
{
use: ['raw-loader', 'pug-plain-loader']
}
]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader'
}
]
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: isProduction() ? 'assets/style.[contenthash].css' : 'assets/style.css'
}),
new HtmlWebpackPlugin({
template: 'src/index.pug'
}),
new webpack.DefinePlugin({
'process.env': {
LINKEDIN_CLIENT_ID: JSON.stringify(process.env.LINKEDIN_CLIENT_ID),
API_URL: JSON.stringify(process.env.API_URL),
MIXPANEL_KEY: JSON.stringify(process.env.MIXPANEL_KEY),
WEB_APP_URL: JSON.stringify(process.env.WEB_APP_URL),
}
}),
new CopyWebpackPlugin([
{
from: 'src/images',
to: 'assets/images'
},
]),
]
};
/* eslint-enable */