Skip to content

Commit 0219880

Browse files
committed
refactor: add barebones basic Webpack build config
1 parent fec1147 commit 0219880

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@
1515
"packages/core/test",
1616
"packages/live-server"
1717
]
18+
},
19+
"dependencies": {
20+
"babel-loader": "^7.1.5",
21+
"webpack": "^4.16.3",
22+
"webpack-stream": "^5.0.0"
1823
}
1924
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// webpack.config.js
2+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
3+
4+
module.exports = {
5+
entry: {
6+
'patternlab-pattern': './src/scripts/patternlab-pattern',
7+
'patternlab-viewer': './src/scripts/patternlab-viewer',
8+
},
9+
output: {
10+
path: `${process.cwd()}/dist/styleguide/js`,
11+
filename: '[name].js',
12+
chunkFilename: `[name]-chunk-[chunkhash].js`,
13+
},
14+
module: {
15+
rules: [
16+
{
17+
test: /\.js$/,
18+
exclude: /(node_modules|bower_components)/,
19+
use: {
20+
loader: 'babel-loader',
21+
options: {
22+
presets: ['@babel/preset-env'],
23+
},
24+
},
25+
},
26+
],
27+
},
28+
cache: true,
29+
mode: 'production',
30+
optimization: {
31+
mergeDuplicateChunks: true,
32+
concatenateModules: true,
33+
minimizer: [
34+
new UglifyJsPlugin({
35+
sourceMap: true,
36+
parallel: true,
37+
cache: true,
38+
uglifyOptions: {
39+
compress: true,
40+
mangle: true,
41+
output: {
42+
comments: false,
43+
beautify: false,
44+
},
45+
},
46+
}),
47+
],
48+
},
49+
plugins: [],
50+
};

0 commit comments

Comments
 (0)