OSDN Git Service

Regular updates
[twpd/master.git] / _support / webpack.config.js
1 const join = require('path').resolve
2 const webpack = require('webpack')
3
4 module.exports = {
5   context: join(__dirname, '..'),
6   entry: {
7     app: './_js/app.js',
8     vendor: [
9       // Large 3rd-party libs
10       'prismjs',
11
12       // Prism plugins
13       'prismjs/plugins/line-highlight/prism-line-highlight.min.js',
14       'prismjs/components/prism-jsx.min.js',
15       'prismjs/components/prism-bash.min.js',
16       'prismjs/components/prism-scss.min.js',
17       'prismjs/components/prism-css.min.js',
18       'prismjs/components/prism-elixir.min.js',
19       'prismjs/components/prism-ruby.min.js',
20
21       // CSS
22       'prismjs/plugins/line-highlight/prism-line-highlight.css',
23       'hint.css/hint.min.css'
24     ]
25   },
26   output: {
27     path: join(__dirname, '..', 'assets', 'packed'),
28     filename: '[name].js',
29     devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]'
30   },
31   module: {
32     rules: [
33       {
34         test: /\.js$/,
35         exclude: /node_modules/,
36         use: [
37           { loader: 'babel-loader' }
38         ]
39       },
40       {
41         test: /\.css$/,
42         use: [
43           { loader: 'style-loader' },
44           { loader: 'css-loader' }
45         ]
46       }
47     ]
48   },
49   resolve: {
50     alias: {
51       // Never bundle jQuery
52       'jquery': join(__dirname, '..', '_js/helpers/noop.js')
53     }
54   },
55   stats: 'minimal',
56   plugins: [
57     // Optimize module ID's for vendor chunks
58     new webpack.HashedModuleIdsPlugin({
59       hashFunction: 'sha256',
60       hashDigest: 'base64',
61       hashDigestLength: 20
62     }),
63
64     // Optimize vendor
65     new webpack.optimize.CommonsChunkPlugin('vendor'),
66
67     // Don't include debug symbols ever
68     new webpack.EnvironmentPlugin({
69       NODE_ENV: 'production'
70     })
71   ],
72   devtool: 'source-map'
73 }