-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.base.js
96 lines (81 loc) · 2.35 KB
/
webpack.base.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
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
// plugins
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
const CopyWebpackPlugin = require('copy-webpack-plugin');
const DefinePlugin = webpack.DefinePlugin;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const assets = [
{from: 'src/assets/vendor.css'},
{from: 'src/assets/images', to: 'images'}
];
exports.loaders = {
html: {test: /\.html$/, loader: 'raw'},
scss: {
common: {test: /\.scss$/, loader: 'style!css!postcss-loader!sass', include: path.resolve('src/views/common/styles')},
components: {test: /\.scss$/, loader: 'raw!postcss-loader!sass', exclude: path.resolve('src/views/common/styles'), include: path.resolve('src/views')},
extract: {test: /\.scss$/, loader: ExtractTextPlugin.extract('css!postcss-loader!sass'), include: path.resolve('src/views/common/styles')}
},
ts: {test: /\.ts$/, loader: 'ts', exclude: /node_modules/}
};
exports.config = {
cache: true,
debug: false,
devtool: 'source-map',
entry: {
main: ['./src/main'],
vendor: [
'es6-shim',
'angular2/bundles/angular2-polyfills',
'angular2/common',
'angular2/core',
'angular2/http',
'angular2/platform/browser',
'angular2/router',
'rxjs'
]
},
output: {
filename: '[name].js',
path: path.resolve('./target'),
publicPath: '/'
},
resolve: {
extensions: ['', '.ts', '.js'],
modulesDirectories: ['node_modules'],
root: path.resolve('.')
},
module: {
loaders: [
exports.loaders.ts,
exports.loaders.html,
exports.loaders.scss.components
],
noParse: [
/angular2\/bundles\/.+/
]
},
postcss: [
autoprefixer({ browsers: ['last 3 versions', 'Firefox ESR'] })
],
sassLoader: {
outputStyle: 'compressed',
precision: 10,
sourceComments: false
},
plugins: [
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js', minChunks: Infinity}),
new CopyWebpackPlugin(assets),
new HtmlWebpackPlugin({
filename: 'index.html',
hash: true,
inject: 'body',
template: './src/index.html'
})
]
};