-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
97 lines (87 loc) · 2.23 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
const webpack = require("webpack");
const path = require("path");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const DIST_DIR = path.resolve(__dirname, "dist");
const SRC_DIR = path.resolve(__dirname, "src");
const VENDORS_DIR = path.resolve(__dirname, "src/app/vendors");
const NODE_MODULES_DIR = path.resolve(__dirname, "node_modules");
const config = {
entry: SRC_DIR + "/app/index.js", // bisa menggunakan object untuk split bundle
output: {
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath: "/app/"
},
module: {
rules: [
{ // loader for js files
test: /\.jsx?$/,
include: SRC_DIR, // include the source file
exclude: [NODE_MODULES_DIR, VENDORS_DIR], // exclude the node_module directory
use: "babel-loader" // using babel loader
},
{ // loader for sass, scss files
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{ // loader for css files
test: /\.css$/,
// Untuk memisahkan file css dari file bundle.js
// akan menghasilkan file style.css
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
exclude: path.resolve(__dirname, "src/app/assests/favico"),
use: [
{ loader: 'url-loader?limit=100000@name=[name][ext]' }
]
},
{
test: /\.ico$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'img/',
publicPath: 'img/'
}
}
]
}
]
},
plugins: [
// Webpack plugin jquery
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
// new webpack.optimize.UglifyJsPlugin({
// compress:{
// warnings: true
// }
// }),
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
ORCINUS_HOST: "localhost",
ORCINUS_PORT: 4000,
ORCINUS_OMURA: "localhost:5009"
}),
// Webpack plugin untuk memisah file css
// agar tidak diinclude ke dalam file
// bundle.js
new ExtractTextPlugin({
filename: '[name].css',
allChunks: true
})
]
};
module.exports = config;