-
Notifications
You must be signed in to change notification settings - Fork 25
/
webpack.config.js
147 lines (142 loc) · 4.57 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const path = require('path')
const webpack = require('webpack')
const publicPath = 'http://localhost:3000/'
const hotMiddlewareScript = 'webpack-hot-middleware/client?reload=true'
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
// const HtmlWebpackPlugin = require('html-webpack-plugin')
let devConfig = {
entry: {
index: ['./public/js/common/header.js', './public/js/common/top_click.js', './public/js/index.js', hotMiddlewareScript],
article: ['./public/js/common/header.js', './public/js/article.js', hotMiddlewareScript],
articlelist: ['./public/js/common/header.js', './public/js/articlelist.js', hotMiddlewareScript],
author: ['./public/js/common/header.js', './public/js/common/top_click.js', './public/js/author.js', hotMiddlewareScript],
login: ['./public/js/common/header.js', './public/js/login.js', hotMiddlewareScript],
register: ['./public/js/common/header.js', './public/js/register.js', hotMiddlewareScript],
result: ['./public/js/common/header.js', './public/js/common/top_click.js', './public/js/result.js', hotMiddlewareScript],
tag: ['./public/js/common/header.js', './public/js/common/top_click.js', './public/js/tag.js', hotMiddlewareScript],
upload: ['./public/js/common/header.js', './public/js/upload.js', hotMiddlewareScript],
manager: ['./public/js/common/header.js', './public/js/manager.js', hotMiddlewareScript],
config: ['./public/js/common/header.js', './public/js/config.js', hotMiddlewareScript],
header: ['./public/js/header.js', hotMiddlewareScript]
},
output: {
path: __dirname + '/public/',
filename: './assets/[name].js',
publicPath: publicPath
},
externals: {
jquery: "window.$"
},
// devtool: 'sourcemap', //在output对应文件生成sourcemap,方便我们在浏览器调试
resolveLoader: {
moduleExtensions: ['-loader']
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
// debug: true,
options: {
/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
// tslint: {
// emitErrors: false,
// failOnHint: false,
// resourcePath: 'client'
// },
}
}),
// new HtmlWebpackPlugin({
// template: './app/views/main/index.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/article.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/admin/articlelist.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/author.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/login.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/register.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/result.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/main/tag.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/admin/setavator.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/admin/password.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/admin/setprofile.ejs'
// }),
// new HtmlWebpackPlugin({
// template: './app/views/manager/config.ejs'
// }),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
module: {
rules: [{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
use: 'url?prefix=font/&limit=10000&name=images/[name].[ext]'
},
// {
// test: /\.ejs$/,
// use: 'raw-loader'
// },
{
test: /\.(tpl|ejs)$/,
use: 'ejs'
},
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
compact: false
}
}]
},
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}]
}
]
}
}
module.exports = devConfig