blob: 642e166423af01b3bfc69bfa07a8f000c09fd818 [file] [log] [blame]
LiYi0784eeb2017-03-02 18:29:04 +08001/* Copyright 2017 ZTE Corporation.
2 *
3 *Licensed under the Apache License, Version 2.0 (the "License");
4 *you may not use this file except in compliance with the License.
5 *You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
YILI1c7effb2017-03-22 14:52:56 +080015const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
16const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
17const CopyWebpackPlugin = require('copy-webpack-plugin');
18const HtmlWebpackPlugin = require('html-webpack-plugin');
19const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
20
21const webpack = require('webpack');
22const helpers = require('./helpers');
23const path = require('path');
24
25
26
LiYi0784eeb2017-03-02 18:29:04 +080027
28
29module.exports = {
30 entry: {
YILI1c7effb2017-03-22 14:52:56 +080031 'main': './alarm/main.browser.ts',
32 'vendor': './alarm/vendor.ts',
33 'polyfills': './alarm/polyfills.browser.ts'
LiYi0784eeb2017-03-02 18:29:04 +080034 },
LiYi0784eeb2017-03-02 18:29:04 +080035 resolve: {
LiYi0784eeb2017-03-02 18:29:04 +080036
YILI1c7effb2017-03-22 14:52:56 +080037 extensions: ['.js', '.ts', '.json'],
38 },
LiYi0784eeb2017-03-02 18:29:04 +080039 module: {
YILI1c7effb2017-03-22 14:52:56 +080040
41 rules: [
LiYi0784eeb2017-03-02 18:29:04 +080042 {
43 test: /\.ts$/,
YILI1c7effb2017-03-22 14:52:56 +080044 use: [
LiYi0784eeb2017-03-02 18:29:04 +080045
YILI1c7effb2017-03-22 14:52:56 +080046 {
47 loader: 'awesome-typescript-loader',
48 options: {
49 }
50 },
51 {
52 loader: 'angular2-template-loader'
53 }
LiYi0784eeb2017-03-02 18:29:04 +080054 ],
YILI1c7effb2017-03-22 14:52:56 +080055 exclude: [/\.(spec|e2e)\.ts$/]
LiYi0784eeb2017-03-02 18:29:04 +080056 },
YILI1c7effb2017-03-22 14:52:56 +080057
58 {
59 test: /\.json$/,
60 use: 'json-loader'
LiYi0784eeb2017-03-02 18:29:04 +080061 },
62 {
63 test: /\.css$/,
YILI1c7effb2017-03-22 14:52:56 +080064 use: ['to-string-loader', 'css-loader?sourceMap'],
LiYibaa263f2017-03-08 10:16:23 +080065 include: helpers.root('alarm', 'app'),
YILI1c7effb2017-03-22 14:52:56 +080066 exclude: [helpers.root('alarm/assets'), helpers.root('public')]
67 },
68 {
69 test: /\.html$/,
70 use: 'raw-loader',
71 include: [helpers.root('alarm/app')],
72 exclude: [helpers.root('alarm/index.html')]
73 },
74
75
76 {
77 test: /\.(png|jpe?g|gif|ico|svg)$/,
78 include: [helpers.root('public')
79 ],
80 use: 'file-loader?name=assets/images/[name].[hash].[ext]'
81 },
82
83
84 {
85 test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
86 include: [helpers.root('public', 'thirdparty')
87 ],
88 use: 'file-loader?name=assets/fonts/[name].[hash].[ext]'
LiYi0784eeb2017-03-02 18:29:04 +080089 }
YILI1c7effb2017-03-22 14:52:56 +080090
91 ],
92
LiYi0784eeb2017-03-02 18:29:04 +080093 },
94
95 plugins: [
YILI1c7effb2017-03-22 14:52:56 +080096
97 new CheckerPlugin(),
98
99 new ContextReplacementPlugin(
100 /angular(\\|\/)core(\\|\/)alarm(\\|\/)linker/,
101 helpers.root('alarm'),
102 {
103 }
104 ),
LiYi0784eeb2017-03-02 18:29:04 +0800105
106 new HtmlWebpackPlugin({
YILI1c7effb2017-03-22 14:52:56 +0800107 template: 'alarm/index.html',
108 }),
109
110 new webpack.optimize.CommonsChunkPlugin({
111 name: ['main', 'vendor', 'polyfills']
112 }),
113
LiYi0784eeb2017-03-02 18:29:04 +0800114 ]
115};