-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwebpack.base.conf.js
More file actions
104 lines (85 loc) · 2.65 KB
/
Copy pathwebpack.base.conf.js
File metadata and controls
104 lines (85 loc) · 2.65 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
const path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.argv.indexOf('-p') !== -1 ? 'production' : 'development';
const ROOT_PATH = path.resolve(__dirname, './');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const sassImports = [
`${ROOT_PATH}/src/sass/includes/_includes.scss`,
`${ROOT_PATH}/src/sass/includes/variables.scss`
];
const isProduction = () => NODE_ENV === 'production';
const isExternal = (module) => {
let userRequest = module.userRequest;
if (typeof userRequest !== 'string') {
return false;
}
return userRequest.indexOf('node_modules') >= 0;
};
process.traceDeprecation = true;
module.exports = {
entry: {
app: './index.js'
},
output: {
path : `${ROOT_PATH}/dist`,
publicPath : '',
filename : 'js/[name].js'
},
context: `${ROOT_PATH}/src`,
stats: {
children: false
},
module: {
rules: [
{
test: /\.html$/,
use: [`ngtemplate-loader?relativeTo=${ROOT_PATH}/src`, 'html-loader'],
exclude: `${ROOT_PATH}/src/index.html`
},
{
test: /\.js$/,
use: ['babel-loader', 'eslint-loader'],
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
use: ['url-loader?limit=8192&name=[path][name].[ext]?[hash]']
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { sourceMap: !isProduction() } },
{ loader: 'postcss-loader', options: { sourceMap: !isProduction() } }
]
})
},
{
test: /\.(sass|scss)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { sourceMap: !isProduction() } },
{ loader: 'postcss-loader', options: { sourceMap: !isProduction() } },
{ loader: 'sass-loader', options: { sourceMap: !isProduction() } },
{ loader: 'sass-resources-loader', options: { resources: sassImports } }
]
})
}
]
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name : 'vendor',
minChunks : (module) => isExternal(module)
}),
new ExtractTextPlugin({
filename : isProduction() ? 'styles/[name].[hash].css' : 'styles/[name].css',
allChunks : true
}),
new FriendlyErrorsPlugin()
]
};