forked from hltj/kotlin-web-site-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
136 lines (120 loc) · 3.02 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
'use strict';
var path = require('path');
var fs = require('fs');
var Webpack = require('webpack');
var WebpackExtractTextPlugin = require('extract-text-webpack-plugin');
var LiveReloadPlugin = require('webpack-livereload-plugin');
var extend = require('extend');
var autoprefixer = require('autoprefixer');
var parseArgs = require('minimist');
var isProduction = process.env.NODE_ENV === 'production';
var isServer = process.argv.toString().includes('webpack-dev-server');
var CLIArgs = parseArgs(process.argv.slice(2));
var webDemoURL = CLIArgs['webdemo-url'] || 'http://kotlin-web-demo-cloud.passive.aws.intellij.net';
var webpackConfig = {
entry: {
'common': 'page/common.js',
'index': 'page/index/index.js',
'events': 'page/events/index.js',
'videos': 'page/videos.js',
'grammar': 'page/grammar.js',
'community': 'page/community/community.js',
'styles': 'styles.scss',
'pdf': 'page/pdf.js',
'api': 'page/api/api.js'
},
output: {
path: path.join(__dirname, '_assets'),
publicPath: '/_assets/',
filename: '[name].js'
},
resolve: {
modulesDirectories: ['node_modules', './static/js', './static/css']
},
devtool: !isProduction ? 'sourcemap' : false,
module: {
loaders: [
{
test: /\.monk$/,
loader: 'monkberry-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, 'static/js')
]
},
{
test: /\.css$/,
loader: WebpackExtractTextPlugin.extract([
'css',
'postcss'
].join('!'))
},
{
test: /\.scss$/,
loader: WebpackExtractTextPlugin.extract([
'css',
'postcss',
'resolve-url?keepQuery',
'sass?sourceMap'
].join('!'))
},
{
test: /\.(woff|ttf)$/,
loader: 'file?name=[path][name].[ext]'
},
{
test: /\.twig$/,
loader: 'nunjucks-loader'
},
{
test: /\.svg/,
loaders: [
'url',
'svg-fill'
]
},
{
test: /\.(jpe?g|png|gif)$/,
loader: 'advanced-url?limit=10000&name=[path][name].[ext]'
}
]
},
postcss: [
autoprefixer({browsers: ['last 2 versions']})
],
plugins: [
new Webpack.optimize.CommonsChunkPlugin({
name: 'default',
minChunks: 3
}),
new Webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
Promise: 'imports?this=>global!exports?global.Promise!core-js/es6/promise'
}),
new Webpack.DefinePlugin({
webDemoURL: JSON.stringify(webDemoURL)
}),
new WebpackExtractTextPlugin('[name].css')
],
devServer: {
proxy: {
'/**': {
target: 'http://localhost:5000'
}
}
}
};
if (!isServer) {
webpackConfig.plugins.push(
new LiveReloadPlugin({
appendScriptTag: false
})
);
}
module.exports = webpackConfig;