forked from bigcommerce/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.conf.js
More file actions
84 lines (83 loc) · 3.33 KB
/
Copy pathwebpack.conf.js
File metadata and controls
84 lines (83 loc) · 3.33 KB
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
var CleanWebpackPlugin = require('clean-webpack-plugin'),
config = require('./config.json'),
LodashModuleReplacementPlugin = require('lodash-webpack-plugin'),
path = require('path'),
webpack = require('webpack');
module.exports = {
bail: true,
context: __dirname,
devtool: 'source-map',
entry: {
main: './assets/js/app.js',
},
module: {
rules: [
{
test: /\.js$/,
include: /(assets\/js|assets\\js|stencil-utils)/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
compact: true,
minified: true,
plugins: [
'dynamic-import-webpack', // Needed for dynamic imports.
'lodash', // Automagically tree-shakes lodash.
'transform-regenerator', // Transforms async and generator functions.
],
presets: [
['env', {
loose: true, // Enable "loose" transformations for any plugins in this preset that allow them.
modules: false, // Don't transform modules; needed for tree-shaking.
useBuiltIns: true, // Tree-shake babel-polyfill.
}],
],
}
}
},
{
test: /jquery-migrate/,
use: 'imports-loader?define=>false',
},
],
},
output: {
chunkFilename: 'theme-bundle.chunk.[name].js',
filename: 'theme-bundle.[name].js',
path: path.resolve(__dirname, "assets/dist"),
},
plugins: [
new CleanWebpackPlugin(['assets/dist'], {
verbose: false,
watch: false,
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
new LodashModuleReplacementPlugin, // Complements 'babel-plugin-lodash by shrinking it's cherry-picked builds further.
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
new webpack.optimize.CommonsChunkPlugin({
children: true,
minChunks: 2,
}),
],
resolve: {
alias: {
'async': path.resolve(__dirname, 'node_modules/async/dist/async.min.js'),
'html5-history-api': path.resolve(__dirname, 'node_modules/html5-history-api/history.min.js'),
jquery: path.resolve(__dirname, 'node_modules/jquery/dist/jquery.min.js'),
'jquery-migrate': path.resolve(__dirname, 'node_modules/jquery-migrate/dist/jquery-migrate.min.js'),
'jquery-zoom': path.resolve(__dirname, 'node_modules/jquery-zoom/jquery.zoom.min.js'),
jstree: path.resolve(__dirname, 'node_modules/jstree/dist/jstree.min.js'),
'pace': path.resolve(__dirname, 'node_modules/pace/pace.min.js'),
'slick-carousel': path.resolve(__dirname, 'node_modules/slick-carousel/slick/slick.min.js'),
sweetalert2: path.resolve(__dirname, 'node_modules/sweetalert2/dist/sweetalert2.min.js'),
},
},
watch: false,
};