Skip to content

Instantly share code, notes, and snippets.

@MatTheCat
Created July 11, 2018 07:50
Show Gist options
  • Save MatTheCat/2e11f1ddbdf8bee2663fa2a5d2a227a2 to your computer and use it in GitHub Desktop.
Save MatTheCat/2e11f1ddbdf8bee2663fa2a5d2a227a2 to your computer and use it in GitHub Desktop.
const glob = require('glob')
const path = require('path')
const webpack = require('webpack')
const input = path.resolve(__dirname, 'src')
const output = path.resolve(__dirname, 'dist')
const entries = {}
glob.sync('page/**/*.js', { cwd: input }).map(function (page) {
entries[page.replace(/\..+$/, '')] = './' + page
})
module.exports = {
context: input,
entry: entries,
output: {
filename: '[name].js',
jsonpFunction: 'loadChunk',
path: output,
publicPath: '/pattern-library/dist/'
},
mode: process.env.WEBPACK_SERVE ? 'development' : 'production',
module: {
rules: [
{
test: /\.less$/,
loader: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'postcss-loader',
{
loader: 'less-loader',
options: {
strictMath: true
}
}
]
},
{
test: /\.css/,
loader: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'postcss-loader'
]
},
{
test: /\.woff2?$/,
loader: 'file-loader'
}
]
},
optimization: {
minimize: false,
runtimeChunk: 'single'
},
plugins: [
new webpack.NamedChunksPlugin(),
new webpack.NamedModulesPlugin()
],
resolve: {
modules: [
'src',
'node_modules'
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment