This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.common.js
95 lines (92 loc) · 2.53 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
92
93
94
95
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Clean = require('clean-webpack-plugin');
const autoprefixer = require('autoprefixer');
module.exports = {
//Entry points(js, scss files)
entry: {
"common": './source/assets/javascripts/common.js',
"search": './source/assets/javascripts/search.js',
"site": './source/assets/stylesheets/site.scss',
"vendor": ["jquery", "bootstrap"],
},
output: {
path: __dirname + '/.tmp/assets/javascripts',
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
},
/*
your other rules for JavaScript transpiling go in here
*/
{ // sass / scss loader for webpack
test: /\.(sass|scss)$/,
loader: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
// grid: true
})
],
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
},
]
})
}
]
},
resolve: {
modules: ['node_modules']
},
plugins: [
new Clean(['.tmp/assets']),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
headroom: 'headroom.js'
}),
new ExtractTextPlugin({ // define where to save the file
filename: '../stylesheets/site.css',
allChunks: true,
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
// filename: "vendor.js"
// (Give the chunk a different name)
minChunks: Infinity,
// (with more entries, this ensures that no other module
// goes into the vendor chunk)
}),
new CopyWebpackPlugin([
{from: __dirname + '/source/assets/javascripts/modernizr', to: __dirname + '/.tmp/assets/javascripts'},
{from: __dirname + '/source/assets/images', to: __dirname + '/.tmp/assets/images'}
]),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
};