This repository has been archived by the owner on Oct 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
98 lines (91 loc) · 2.75 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var rootAssetPath = './app/assets';
config = {
context: path.resolve(__dirname, './app/assets'),
entry: {
app_js: [
'scripts/index'
],
app_css: [
'styles/main.scss'
]
},
devServer: {
headers: { "Access-Control-Allow-Origin": "*" }
},
output: {
path: path.resolve(__dirname, './app/static/dist'),
publicPath: 'http://localhost:2992/assets/',
filename: '[name].[chunkhash].js',
chunkFilename: '[id].[chunkhash].js'
},
resolve: {
extensions: ['.js', '.css', '.scss'],
modules: [
path.resolve(__dirname, './app/assets/'),
'node_modules'
],
},
module: {
rules: [
{
test: /\.js$/i,
use: [
'ng-annotate-loader',
'babel-loader'
],
exclude: [/node_modules/],
},
// {
// test: /\.(jpe?g|png|gif|svg([\?]?.*))$/i,
// loaders: [
// 'file?context=' + rootAssetPath + '&name=[path][name].[hash].[ext]',
// 'image?bypassOnDebug&optimizationLevel=7&interlaced=false'
// ]
// },
{
test: /\.html$/,
use: ['ngtemplate-loader?relativeTo=' + path.join(__dirname, rootAssetPath), 'raw-loader', 'html-minify-loader'],
exclude: [/(node_modules)/]
},
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
use: ["file-loader"]
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
'css-loader', 'sass-loader'
]
})
}
],
},
plugins: [
new ExtractTextPlugin({
filename:'[name].[chunkhash].css'
}),
new ManifestRevisionPlugin(path.join('app/static', 'manifest.json'), {
rootAssetPath: rootAssetPath,
ignorePaths: ['/styles', '/scripts']
}),
]
};
if (process.env.NODE_ENV === 'prod') {
config.output.publicPath = '/static/dist/';
config.plugins.push(new CleanWebpackPlugin(['app/static/dist/'], {
verbose: true,
dry: false
}));
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
}
module.exports = config;