-
Notifications
You must be signed in to change notification settings - Fork 196
/
webpack.common.js
executable file
·91 lines (91 loc) · 3.03 KB
/
webpack.common.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
// LICENSE_CODE ZON ISC
'use strict'; /*jslint node:true*/
const webpack = require('webpack');
const html_webpack_plugin = require('html-webpack-plugin');
const mk_url_loader = mimetype=>[{
loader: 'url-loader',
options: {limit: '100000', fallback: 'file-loader', mimetype},
}];
module.exports = {
context: `${__dirname}/src/`,
entry: {
app: './pub/app.js',
vendor: ['jquery', 'lodash4', 'moment', 'bootstrap',
'bootstrap/dist/css/bootstrap.css', 'codemirror/lib/codemirror',
'codemirror/lib/codemirror.css', 'react-bootstrap', 'react',
'codemirror/mode/javascript/javascript', 'react-dom',
'regenerator-runtime', 'es6-shim', 'animate.css'],
},
output: {
path: `${__dirname}/bin/pub`,
publicPath: '/',
filename: '[chunkhash].[name].js',
},
plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new html_webpack_plugin({inject: true, template: './pub/index.html'}),
],
optimization: {
runtimeChunk: 'single',
minimize: false,
},
watchOptions: {
poll: true,
ignored: /node_modules/
},
module: {
rules: [
{
test: /src[\\/]pub[\\/].+\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /src[\\/]pub2[\\/].+\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /www[\\/].+\.js$/,
exclude: /node_modules/,
use: ['hutil-loader', 'babel-loader'],
},
{
test: /util[\\/].+\.js$/,
parser: {node: false, commonjs: false},
exclude: [/www[\\/].+\.js$/, /node_modules/],
use: ['hutil-loader'],
},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{test: /\.less$/, use: ['style-loader', 'css-loader?-url',
'less-loader']},
{test: /\.eot(\?v=\d+.\d+.\d+)?$/, use: mk_url_loader()},
{test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: mk_url_loader('application/font-woff')},
{test: /\.[ot]tf(\?v=\d+.\d+.\d+)?$/,
use: mk_url_loader('application/octet-stream')},
{test: /\.svg(\?v=\d+.\d+.\d+)?$/,
use: mk_url_loader('image/svg+xml')},
{test: /\.(jpe?g|png|ico|gif)$/, use: mk_url_loader()},
],
},
resolve: {
modules: [__dirname, 'node_modules'],
alias: {
'/util': 'util/',
jquery: 'jquery/src/jquery.js',
virt_jquery_all: 'jquery/src/jquery.js',
'/www': 'www/',
},
},
resolveLoader: {
alias: {'hutil-loader': `${__dirname}/lib/hutil_loader.js`},
},
};