-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathwebpack.config.js
More file actions
154 lines (139 loc) · 4.59 KB
/
webpack.config.js
File metadata and controls
154 lines (139 loc) · 4.59 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const webpack = require('webpack');
const WebpackMd5Hash = require('webpack-md5-hash');
const AssetsPlugin = require('assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ConcatPlugin = require('webpack-concat-plugin');
const path = require('path');
const pkg = require('./package.json');
require("babel-core/register");
require("babel-polyfill");
module.exports = {
entry: {
main: [
'babel-polyfill',
'./src/js/app.js',
'./src/js/controllers.js',
'./src/js/directives.js',
'./src/js/filters.js',
'./src/js/services.js'
],
vendor_node: Object.keys(pkg.dependencies)
},
devServer: {
inline: true,
hot: false
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'js/[name].js',
chunkFilename: 'js/[name]-[chunkhash].js',
jsonpFunction: 'webpackJsonp',
// publicPath: '/js/'
},
plugins: [
// Extract all 3rd party modules into a separate 'vendor' chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor_node',
minChunks: ({ resource }) => /node_modules/.test(resource)
}),
new ConcatPlugin({
uglify: false,
sourceMap: false,
name: 'vendor',
outputPath: 'js/',
fileName: 'vendor.js',
filesToConcat: ['./src/js/vendor/**'],
attributes: {
async: true
}
}),
new ExtractTextPlugin('[name].[chunkhash].css'),
// Generate a 'manifest' chunk to be inlined in the HTML template
new webpack.optimize.CommonsChunkPlugin('manifest'),
// Need this plugin for deterministic hashing
// until this issue is resolved: https://github.com/webpack/webpack/issues/1315
// for more info: https://webpack.js.org/how-to/cache/
new WebpackMd5Hash(),
// Creates a 'webpack-assets.json' file with all of the
// generated chunk names so you can reference them
new AssetsPlugin(),
new CopyWebpackPlugin([
{from:'src/views',to:'views'},
{from:'src/assets',to:'assets'},
{from:'arduino/',to:'assets/arduino'},
{from:'src/index.html',to:'index.html'},
{from:'src/favicon.ico',to:'favicon.ico'},
{from:'package.json',to:'package.json'},
{from:'src/styles/app.css',to:'styles/app.css'},
{from: './node_modules/angularjs-slider/dist/rzslider.min.css', to: 'styles/vendor.css'}
]),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
// In case you imported plugins individually, you must also require them here:
Util: "exports-loader?Util!bootstrap/js/dist/util",
Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
}),
new BrowserSyncPlugin(
// BrowserSync options
{
// browse to http://localhost:3000/ during development
host: 'localhost',
port: 8000,
// proxy the Webpack Dev Server endpoint
// (which should be serving on http://localhost:3100/)
// through BrowserSync
// proxy: 'http://localhost:3100/',
server: { baseDir: ['build'] },
ui: false
// ui: {
// port: 8080
// }
},
// plugin options
{
// prevent BrowserSync from reloading the page
// and let Webpack Dev Server take care of this
reload: true
}),
new ExtractTextPlugin("styles/[name].css"),
new WriteFilePlugin(),
],
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.html$/,
include: [
path.resolve('./src'),
path.resolve('./src/views')
],
loader: "html"
},
{
test: /\.scss$/,
include: path.resolve('./src/styles'),
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
}
]
},
node: {
dns: 'mock',
net: 'empty',
dgram: 'empty'
},
devtool: '#inline-source-map'
};