-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
105 lines (99 loc) · 2.88 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
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require('autoprefixer');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const BUILD_DIR = path.resolve(__dirname, 'public/assets');
const APP_DIR = path.resolve(__dirname, 'src');
const BOWER_DIR = path.resolve(__dirname, 'bower_components');
const plugins = [
new webpack.EnvironmentPlugin(['NODE_ENV', 'APP_VERSION', 'API_BASE_URL', 'GOOGLE_MAPS_API_KEY']),
new MiniCssExtractPlugin({filename: 'style.css'}),
new webpack.LoaderOptionsPlugin({ options: {} })
];
if (process.env.NODE_ENV === 'production') {
plugins.push(new UglifyJSPlugin({ sourceMap: true }));
}
const config = {
entry: APP_DIR + '/index.js',
output: {
path: BUILD_DIR,
filename: 'bundle.js',
publicPath: (
'/assets/'
),
},
devtool: (
process.env.NODE_ENV === 'production' ?
'source-map' : 'inline-source-map'
),
module: {
rules: [
{
test: /\.json$/,
type: 'javascript/auto',
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'json-loader',
}],
},
{
test: /\.ejs/,
use: [
'ejs-compiled-loader',
]
},
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [
'babel-loader',
]
},
{
test: /\.s(c|a)ss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{
loader: 'css-loader',
options: {
minimize: true
},
},
{
loader: 'postcss-loader',
options: {
plugins: function() {
return [autoprefixer('last 2 versions', 'ie 10')];
}
}
},
{ loader: "sass-loader" }
],
}
],
},
resolve: {
modules: [APP_DIR, 'node_modules'],
extensions: ['.js', '.jsx', '.json'],
alias: {
'jquery': path.join(BOWER_DIR, '/jquery/dist/jquery.js'),
'pickadate-picker': path.join(BOWER_DIR, '/pickadate/lib/picker.js'),
'pickadate-date': path.join(BOWER_DIR, '/pickadate/lib/picker.date.js'),
'pickadate-time': path.join(BOWER_DIR, '/pickadate/lib/picker.time.js'),
'picker': path.join(BOWER_DIR, '/pickadate/lib/picker.js'),
'pickadate-it': path.join(BOWER_DIR, '/pickadate/lib/translations/it_IT.js'),
// overwrite this useless package
'codemirror-spell-checker': path.join(APP_DIR, '/vendor/codemirror-spell-checker/index.js')
},
},
plugins,
devServer: {
contentBase: './public',
port: 3001,
historyApiFallback: true,
disableHostCheck: true
}
};
module.exports = config;