This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.babel.js
100 lines (94 loc) · 2.75 KB
/
webpack.config.babel.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
import fs from 'fs-extra'
import path from 'path'
import webpack from 'webpack'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
const isProd = process.env.NODE_ENV === 'production'
const webpackMode = process.env.NODE_ENV
console.log('running in ' + webpackMode + ' mode!')
const folders = {
dist: path.join(__dirname, 'dist/'),
src: path.join(__dirname, 'src/')
}
// Move index file to dist directory
fs.copy(`${folders.src}index.html`, `${folders.dist}index.html`, function (err) {
if (err) return console.error(err)
});
// Move icons to dist directory
fs.mkdirsSync(folders.dist + "/icons")
fs.copy(folders.src + "images/icons", folders.dist + "/icons/", function (err) {
if (err) return console.error(err)
});
//setup webpack plugins
const plugins = [
new MiniCssExtractPlugin({filename: '[name].css'}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version),
RELEASE: JSON.stringify(require("./package.json").release),
SITE_URL: JSON.stringify(require("./package.json").site_url)
})
]
if (isProd) {
plugins.push(new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}))
}
export default {
entry: {
'main': ["regenerator-runtime/runtime.js",`${folders.src}entry.jsx`],
'vendor': [`${folders.src}/vendor/index.js`]
},
mode: webpackMode,
output: {
path: `${folders.dist}assets/`,
publicPath: '/assets/',
filename: '[name].bundle.js'
},
devServer: {
contentBase: './dist',
progress: true,
watchContentBase: true,
port: 3545
},
module: {
// noParse: [/aws-sdk/],
rules: [
{
test: /\.scss$/,
exclude: /node_modules/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(jpg|png|gif|ico|woff)$/,
loader: 'url-loader?limit=65536&name=[name].[ext]'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
},
{
test: /\.(es|jsx)$/,
exclude: /node_modules/,
loaders: ['babel-loader']
},
{
test: /\.(mss|sql)$/,
loader: 'raw-loader'
}
]
},
resolve: {
// allows extension-less require/import statements for files with these extensions
extensions: ['.es', '.js', '.jsx'],
alias: {
leaflet_css: __dirname + '/node_modules/leaflet/dist/leaflet.css',
leaflet_marker: __dirname + '/node_modules/leaflet/dist/images/marker-icon.png',
leaflet_marker_2x: __dirname + '/node_modules/leaflet/dist/images/marker-icon-2x.png',
leaflet_marker_shadow: __dirname + '/node_modules/leaflet/dist/images/marker-shadow.png'
}
},
plugins
}