-
Notifications
You must be signed in to change notification settings - Fork 21
/
webpack.config.js
117 lines (108 loc) · 2.73 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
const path = require('path');
const fs = require('fs');
const extractTextPlugin = require("extract-text-webpack-plugin");
// style
const postcssImport = require('postcss-import');
const postcssURL = require('postcss-url');
const cssnext = require('postcss-cssnext');
const fontMagician = require('postcss-font-magician');
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = [
{
name: 'server',
entry: './server/server.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js'
},
externals: nodeModules
},
{
name: 'client',
entry: [
'jquery/',
'./client/client.js',
],
// target: 'web', // by default
output: {
path: path.join(__dirname, 'public', 'build'),
filename: 'app.js',
},
resolve: {
extensions: ['', '.js', '.vue', '.json'],
fallback: [path.join(__dirname, './node_modules')],
alias: {
'vue$': path.join(__dirname, './node_modules/vue/dist/vue.common.js'),
'vue-router$': path.join(__dirname, './node_modules/vue-router/dist/vue-router.common.js'),
}
},
module: {
preLoaders: [
{ test: /\.css$/, loader: 'stylelint' }
],
loaders: [
// {
// test:/bootstrap-sass[\/\\]assets[\/\\]javascripts[\/\\]/,
// loader: 'imports?jQuery=jquery'
// },
{
test: /\.vue$/,
loader: 'vue',
options: {
// vue-loader options go here
}
},
// Extract css files
{
test: /\.css$/,
loader: extractTextPlugin.extract("style-loader", "css-loader!postcss")
},
// ES2015
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
},
{
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url?limit=10000"
},
{
test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
loader: 'file'
}
]
},
plugins: [
new extractTextPlugin("app.css", {
allChunks: true
})
],
stylelint: {
configFile: path.join(__dirname, './stylelint.config.js'),
configOverrides: {
rules: {
// Your rule overrides here
}
}
},
postcss: [
// inline @import need to merge vars
postcssImport(),
fontMagician({
hosted: path.join(__dirname, './public/fonts/Roboto')
}),
postcssURL(),
require('postcss-hexrgba')(),
cssnext()
]
}
];