-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
108 lines (96 loc) · 2.56 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
var webpack = require('webpack');
var path = require('path');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var srcPath = path.join(__dirname, '/base/assets/scripts/app/');
var dstPath = path.join(__dirname, '/base/assets/scripts/app/build/');
var entry = path.join(srcPath, 'app.module.es6')
var ExtractTextPlugin = require("extract-text-webpack-plugin");
// Plugins
var extractSass = new ExtractTextPlugin({
filename: "css/main.bundle.css"
});
var bundleVendor = new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'js/vendor.bundle.js'
});
var jqueryProvider = new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
Popper: ['popper.js', 'default'],
})
module.exports = {
context: srcPath,
entry: {
app: entry,
vendor: ['jquery', 'angular', 'bootstrap', ]
},
output: {
path: dstPath,
filename: "js/app.bundle.js"
},
plugins: [
bundleVendor,
extractSass,
jqueryProvider
],
watch: true,
module: {
rules: [
// HTML
{
test: /\.html$/,
loader: 'html-loader'
},
// Stylesheets
{
test: /\.(scss|sass|css)$/,
use: extractSass.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
// use style-loader in development
fallback: "style-loader"
})
},
// Fonts
{
test: /\.(ttf|eot|woff|woff2|svg)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
publicPath: '../'
},
},
// copy assets to output
{
test: /\.(png|jpe?g|gif|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
query: {
name: 'images/[name].[ext]',
publicPath: '../'
}
},
// ES6 Support
{
test: /\.es6$/,
exclude: /node_modules/,
use: [
{
loader: 'angular2-template-loader?useAbsoluteUrls=true'
},
{
loader: 'ng-annotate-loader'
},
{
loader: 'babel-loader',
options: {
plugins: ['transform-runtime']
}
},
],
},
] // end rules
},
};