-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
90 lines (86 loc) · 2.76 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
/**
* Created by xiaolin on 2017-12-11.
* Copyright 2017 air. All rights reserved.
*/
'use strict'
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const ISDEV = process.env.NODE_ENV === "development";
const buildPath = ISDEV ? "/cloud-home-dev" : "/cloud-home-prd";
const extractSass = new ExtractTextPlugin({
filename: "css/app.css"
});
module.exports = {
entry: [path.resolve(__dirname, "src/pages/app.tsx")],
output: {
path: path.resolve(__dirname, "build" + buildPath),
filename: "js/app.js"
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.scss', 'css'],
alias: {
'mui': path.resolve(__dirname, 'src/public/js/mui.min.js'),
'flexible': path.resolve(__dirname, 'src/public/js/flexible.min.js'),
'layer': path.resolve(__dirname, 'src/public/js/layer_mobile/layer.js'),
'pullToRefresh': path.resolve(__dirname, 'src/public/js/mui.pullToRefresh.js'),
'city': path.resolve(__dirname, 'src/public/js/city.js')
}
},
module: {
rules: [{
test: /\.tsx?$/,
loader: "awesome-typescript-loader"
},
{
test: /\.(png|jpg|jpeg|gif)$/,
use: [{ loader: 'url-loader', options: { limit: 10, publicPath: '../', name: 'images/[name].[ext]' } }]
},
{
test: /\.(ttf|eot|woff|svg)$/,
use: [{
loader: 'file-loader',
options: { publicPath: '../', name: 'icons/[name].[ext]' }
}]
},
{
test: /\.(scss)$/,
use: extractSass.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
fallback: "style-loader"
})
}
]
},
plugins: [
new CopyWebpackPlugin([{
from: 'manifest.json',
to: 'manifest.json'
},
{
from: 'src/public/css',
to: 'css'
},
{
from: 'src/public/fonts',
to: 'fonts'
}
]),
new HtmlWebpackPlugin({
filename: 'html/index.html',
minify: {
collapseWhitespace: !ISDEV
},
template: path.resolve(__dirname, "index.html")
}),
extractSass
]
};