This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
73 lines (66 loc) · 2.21 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
const toolset = require('./storage/build/scripts/webpack/toolset.js');
const DefinePlugin = require("webpack/lib/DefinePlugin");
const ManifestPlugin = require('webpack-manifest-plugin');
const path = require('path');
const merge = require('webpack-merge');
const PATHS = {
js: path.join(__dirname, 'resources', 'assets', 'javascripts'),
scss: path.join(__dirname, 'resources', 'assets', 'sass'),
css: path.join(__dirname, 'resources', 'assets', 'stylesheets'),
build: path.join(__dirname, 'public', 'build')
};
let common = {
entry: {
register: path.join(PATHS.js, 'register.js'),
login: path.join(PATHS.js, 'login.js'),
auth: path.join(PATHS.js, 'auth.js'),
file: path.join(PATHS.js, 'file.js'),
admin: path.join(PATHS.js, 'admin.js')
},
output: {
path: PATHS.build,
publicPath: '/build/',
filename: process.env.npm_lifecycle_event == 'build' ? '[name].[chunkhash].js' : '[name].js', // Don't use [chunkhash] in dev environment, it increases compilation time.
chunkFilename: '[chunkhash].js' // This is used for require.ensure. The setup will work without but this is useful to set.
},
plugins: [
new ManifestPlugin({
fileName: 'rev-manifest.json'
})
],
resolve: {
alias: {
pace: 'pace-progress/pace.js',
jquery: 'jquery/src/jquery'
}
}
};
let config;
// Detect how npm is run and branch based on that
switch (process.env.npm_lifecycle_event) {
case 'build': // For production environment.
config = merge(
common,
{
devtool: 'source-map'
},
toolset.clean(PATHS.build),
toolset.loadersAndPluginsForVariousTypes(),
toolset.extractBundles(),
toolset.minify()
);
break;
default: // For a dev environment.
config = merge(
common,
{
devtool: 'eval-source-map'
},
toolset.clean(PATHS.build),
// toolset.styles()
toolset.loadersAndPluginsForVariousTypes(),
toolset.extractBundles()
);
break;
}
module.exports = config;