-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.common.js
106 lines (97 loc) · 2.53 KB
/
webpack.common.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
// Shared Webpack Configuration
// Plugins
const webpack = require('webpack'); // webpack built-in plugins
const HtmlWebpackPlugin = require('html-webpack-plugin');
const sGrid = require('s-grid');
const AutoprefixerStylus = require('autoprefixer-stylus');
// Helper for resolving paths
const helpers = require('./helpers.js');
module.exports = {
entry: {
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.json'
}
},
{
loader: 'angular2-template-loader',
}
],
include: [helpers.root('src'), helpers.root('node_modules', '@encurate')],
exclude: [/\.(spec|e2e)\.ts$/, /node_modules\/(?!(@encurate)\/).*/]
},
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: 'file-loader?name=img/[name].[hash].[ext]'
},
{
test: /\.styl$/,
use: [
'raw-loader',
'stylus-loader',
],
include: [helpers.root('src', 'app')],
exclude: [helpers.root('node_modules'), helpers.root('src', 'styles')]
},
{
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
'stylus-loader',
],
include: [helpers.root('src', 'styles')],
exclude: [helpers.root('node_modules'), helpers.root('src', 'app')]
},
]
},
plugins: [
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./app'), // location of your app
{} // a map of your routes
),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor']
}),
new HtmlWebpackPlugin({
template: './src/index.html',
favicon: './src/favicon.ico',
// title: 'Dev CMS',
}),
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
}),
new webpack.LoaderOptionsPlugin({
test: /\.styl$/,
stylus: {
default: {
use: [
sGrid(),
AutoprefixerStylus(),
],
},
},
}),
],
};