1 |
|
2 | 'use strict';
|
3 | const webpack = require('webpack');
|
4 | const html_webpack_plugin = require('html-webpack-plugin');
|
5 | module.exports = {
|
6 | context: `${__dirname}/src/pub`,
|
7 | entry: {
|
8 | app: './app.js',
|
9 | vendor: ['jquery', 'lodash', 'moment',
|
10 | 'bootstrap', 'bootstrap/dist/css/bootstrap.css',
|
11 | 'codemirror/lib/codemirror', 'codemirror/lib/codemirror.css',
|
12 | 'codemirror/mode/javascript/javascript',
|
13 | 'react', 'react-dom', 'react-bootstrap',
|
14 | 'regenerator-runtime', 'es6-shim', 'animate.css']
|
15 | },
|
16 | output: {
|
17 | path: `${__dirname}/bin/pub`,
|
18 | publicPath: '/',
|
19 | filename: '[chunkhash].[name].js',
|
20 | },
|
21 | plugins: [
|
22 | new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
23 | new webpack.optimize.CommonsChunkPlugin({
|
24 | names: ['vendor', 'runtime'],
|
25 | minChunks: Infinity,
|
26 | }),
|
27 | new webpack.ProvidePlugin({
|
28 | $: 'jquery',
|
29 | jQuery: 'jquery',
|
30 | }),
|
31 | new html_webpack_plugin({inject: true, template: 'index.html'}),
|
32 | ],
|
33 | module: {
|
34 | rules: [
|
35 | {
|
36 | test: /src[\\\/]pub[\\\/].+\.js$/,
|
37 | exclude: /node_modules/,
|
38 | use: ['babel-loader'],
|
39 | },
|
40 | {
|
41 | test: /www[\\\/].+\.js$/,
|
42 | exclude: /node_modules/,
|
43 | use: ['hutil-loader', 'babel-loader'],
|
44 | },
|
45 | {
|
46 | test: /util[\\\/].+\.js$/,
|
47 | parser: {node: false, commonjs: false},
|
48 | exclude: [/www[\\\/].+\.js$/, /node_modules/],
|
49 | use: ['hutil-loader'],
|
50 | },
|
51 | {test: /\.css$/, use: ['style-loader', 'css-loader']},
|
52 | {test: /\.less$/, use: ['style-loader', 'css-loader?-url',
|
53 | 'less-loader']},
|
54 | {test: /\.eot(\?v=\d+.\d+.\d+)?$/,
|
55 | use: 'url-loader?limit=100000&name=[name].[ext]'},
|
56 | {test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?'
|
57 | +'limit=100000&mimetype=application/font-woff&'
|
58 | +'name=[name].[ext]'},
|
59 | {test: /\.[ot]tf(\?v=\d+.\d+.\d+)?$/, use: 'url-loader?'
|
60 | +'limit=100000&mimetype=application/octet-stream'},
|
61 | {test: /\.svg(\?v=\d+.\d+.\d+)?$/, use: 'url-loader?'
|
62 | +'limit=120000&mimetype=image/svg+xml&name=[name].[ext]'},
|
63 | {test: /\.(jpe?g|png|ico|gif)$/, use: 'url-loader?limit=100000'},
|
64 | ],
|
65 | },
|
66 | resolve: {
|
67 | modules: [__dirname, 'node_modules'],
|
68 | alias: {
|
69 | '/util': 'util/',
|
70 | jquery: 'jquery/src/jquery.js',
|
71 | virt_jquery_all: 'jquery/src/jquery.js',
|
72 | '/www': 'www/',
|
73 | },
|
74 | },
|
75 | resolveLoader: {
|
76 | alias: {'hutil-loader': `${__dirname}/lib/hutil-loader.js`},
|
77 | },
|
78 | };
|