forked from petroved/matrix42-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
140 lines (130 loc) · 3.3 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
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
'use strict';
// Depends
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer-core');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var stylesLoader = 'css-loader?sourceMap!postcss-loader!sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true';
const paths = {
src: 'src',
dist: 'dist',
};
module.exports = {
// entry points
entry: {
vendor: path.resolve(path.join(paths.src, '/app/index.vendor.js')),
app: path.resolve(path.join(paths.src, '/app/index.bootstrap.js')),
},
// output system
output: {
path: paths.dist,
filename: '[name].[hash].js',
publicPath: '/'
},
// resolves modules
resolve: {
extensions: ['', '.js', '.css', '.json'],
modulesDirectories: ['node_modules'],
},
module: {
preLoaders: [{
test: /\.js$/,
include: [
path.resolve(path.join(paths.src, 'app')),
],
loader: 'eslint-loader',
}],
loaders: [
{
test: /\.html$/,
loaders: [
'ngtemplate-loader?relativeTo='+ paths.src,
'html-loader?attrs[]=img:src&attrs[]=img:data-src'
]
},
{
test: /\.js$/,
loaders: [
'baggage-loader?[file].html&[file].css'
]
},
{
test: /\.js$/,
include: [
path.resolve(path.join(paths.src, 'app')),
],
loaders: [
'ng-annotate-loader'
]
},
{
test: /\.js$/,
include: [
path.resolve(path.join(paths.src, 'app')),
],
loader: 'babel-loader',
query: {
cacheDirectory: true,
plugins: ['transform-runtime', 'add-module-exports'],
presets: ['angular', 'es2017']
}
},
{
test: /\.css$/,
loaders: [
'style-loader',
'css-loader?sourceMap',
'postcss-loader'
]
},
{
test: /\.(scss|sass)$/,
include: [
path.resolve(path.join(paths.src, 'app')),
],
loader: ExtractTextPlugin.extract('style-loader', stylesLoader)
},
{
test: /\.(woff2|woff|ttf|eot|svg)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: [
'url-loader?name=assets/fonts/[name]_[hash].[ext]'
]
},
{
test: require.resolve('angular'),
loaders: [
'expose?angular'
]
},
]
},
// post css
postcss: [autoprefixer({ browsers: ['last 3 versions'] })],
// load plugins
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.AggressiveMergingPlugin({
moveToParents: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
async: true,
children: true,
minChunks: Infinity,
}),
new ExtractTextPlugin('assets/styles/[name].[chunkhash].css', { allChunks: true }),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(paths.src, 'index.html'),
inject: 'body',
}),
// new webpack.optimize.UglifyJsPlugin({
// minimize: true,
// warnings: false,
// sourceMap: false
// })
],
devtool: 'cheap-source-map',
};