LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 1 | /* 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 | */
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 15 | const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
|
| 16 | const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
|
| 17 | const CopyWebpackPlugin = require('copy-webpack-plugin');
|
| 18 | const HtmlWebpackPlugin = require('html-webpack-plugin');
|
| 19 | const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
|
| 20 |
|
| 21 | const webpack = require('webpack');
|
| 22 | const helpers = require('./helpers');
|
| 23 | const path = require('path');
|
| 24 |
|
| 25 |
|
| 26 |
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 27 |
|
| 28 |
|
| 29 | module.exports = {
|
| 30 | entry: {
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 31 | 'main': './alarm/main.browser.ts',
|
| 32 | 'vendor': './alarm/vendor.ts',
|
| 33 | 'polyfills': './alarm/polyfills.browser.ts'
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 34 | },
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 35 | resolve: {
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 36 |
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 37 | extensions: ['.js', '.ts', '.json'],
|
| 38 | },
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 39 | module: {
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 40 |
|
| 41 | rules: [
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 42 | {
|
| 43 | test: /\.ts$/,
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 44 | use: [
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 45 |
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 46 | {
|
| 47 | loader: 'awesome-typescript-loader',
|
| 48 | options: {
|
| 49 | }
|
| 50 | },
|
| 51 | {
|
| 52 | loader: 'angular2-template-loader'
|
| 53 | }
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 54 | ],
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 55 | exclude: [/\.(spec|e2e)\.ts$/]
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 56 | },
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 57 |
|
| 58 | {
|
| 59 | test: /\.json$/,
|
| 60 | use: 'json-loader'
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 61 | },
|
| 62 | {
|
| 63 | test: /\.css$/,
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 64 | use: ['to-string-loader', 'css-loader?sourceMap'],
|
LiYi | baa263f | 2017-03-08 10:16:23 +0800 | [diff] [blame] | 65 | include: helpers.root('alarm', 'app'),
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 66 | 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]'
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 89 | }
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 90 |
|
| 91 | ],
|
| 92 |
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 93 | },
|
| 94 |
|
| 95 | plugins: [
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 96 |
|
| 97 | new CheckerPlugin(),
|
| 98 |
|
| 99 | new ContextReplacementPlugin(
|
| 100 | /angular(\\|\/)core(\\|\/)alarm(\\|\/)linker/,
|
| 101 | helpers.root('alarm'),
|
| 102 | {
|
| 103 | }
|
| 104 | ),
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 105 |
|
| 106 | new HtmlWebpackPlugin({
|
YILI | 1c7effb | 2017-03-22 14:52:56 +0800 | [diff] [blame] | 107 | template: 'alarm/index.html',
|
| 108 | }),
|
| 109 |
|
| 110 | new webpack.optimize.CommonsChunkPlugin({
|
| 111 | name: ['main', 'vendor', 'polyfills']
|
| 112 | }),
|
| 113 |
|
LiYi | 0784eeb | 2017-03-02 18:29:04 +0800 | [diff] [blame] | 114 | ]
|
| 115 | };
|