BookStack/webpack.config.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

2018-03-11 12:16:30 -04:00
const path = require('path');
const dev = process.env.NODE_ENV !== 'production';
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
2018-03-11 12:16:30 -04:00
const config = {
target: 'web',
mode: dev? 'development' : 'production',
2018-03-11 12:16:30 -04:00
entry: {
app: './resources/assets/js/index.js',
styles: './resources/assets/sass/styles.scss',
"export-styles": './resources/assets/sass/export-styles.scss',
"print-styles": './resources/assets/sass/print-styles.scss',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'public/dist')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [{
loader: "css-loader", options: {
sourceMap: dev
}
}, {
loader: 'postcss-loader',
options: {
ident: 'postcss',
sourceMap: dev,
plugins: (loader) => [
require('autoprefixer')(),
]
}
}, {
loader: "sass-loader", options: {
sourceMap: dev
}
}]
})
2018-03-11 12:16:30 -04:00
}
]
},
plugins: [
new ExtractTextPlugin("[name].css"),
]
2018-03-11 12:16:30 -04:00
};
if (dev) {
config['devtool'] = 'inline-source-map';
}
if (!dev) {
config.plugins.push(new UglifyJsPlugin());
}
module.exports = config;