Skip to content

Instantly share code, notes, and snippets.

@oshihirii
Last active August 27, 2019 08:18
Show Gist options
  • Save oshihirii/3facf1112ce14bc1e0a484f4f8ccd1e8 to your computer and use it in GitHub Desktop.
Save oshihirii/3facf1112ce14bc1e0a484f4f8ccd1e8 to your computer and use it in GitHub Desktop.
just the config i use, I’m sure it could be better but it’s worked for me for a while.
const path = require('path');
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// see: https://stackoverflow.com/a/28989476
var webpack = require("webpack");
console.log("the __dirname is: " + __dirname);
module.exports = {
mode: "production",
entry: "./src/js/common.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist/js")
},
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: {
presets: ["env", "stage-0"]
}
}
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
},
{
test: /\.less$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" },
{ loader: "less-loader" }
]
},
{
test: /\.jpg$/,
use: [
{ loader: "url-loader" }
]
},
{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: '$'
}]
},
{
test: require.resolve('js-cookie'),
use: [{
loader: 'expose-loader',
options: 'Cookies'
}]
}
]
},
plugins: [
new UglifyJsPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
resolve: {
alias: {
'uikit-util': path.resolve(__dirname, 'node_modules/uikit/src/js/util')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment