snip/webpack.common.js

57 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2020-10-26 16:17:00 +00:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
2020-11-05 23:46:58 +00:00
const autoprefixer = require('autoprefixer');
2020-10-26 16:17:00 +00:00
module.exports = {
entry: {
2020-11-05 23:46:58 +00:00
index: './snip/templates/index.js',
success: './snip/templates/success.js'
2020-10-26 16:17:00 +00:00
},
plugins: [
new CleanWebpackPlugin()
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'snip', 'static', 'dist')
},
module: {
2020-10-29 23:59:31 +00:00
rules: [
{
test: /\.css$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
2020-11-05 23:46:58 +00:00
'css-loader',
// - runs autoprefixer
// - must come after css/style-loader but before other preprocessors
// - webpack evaluates right to left/bottom to top
// - Browser compatibility list determined by https://get.foundation/sites/docs/sass.html
{loader: 'postcss-loader',
options: { postcssOptions:
{ plugins:
['postcss-preset-env', { 'browsers': ['last 2 versions', 'ie >= 9', 'android >= 4.4', 'ios >= 7']}]}}}
2020-10-29 23:59:31 +00:00
]
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
2020-11-05 23:46:58 +00:00
// - runs autoprefixer
// - must come after css/style-loader but before other preprocessors
// - webpack evaluates right to left/bottom to top
// - Browser compatibility list determined by https://get.foundation/sites/docs/sass.html
{loader: 'postcss-loader',
options: { postcssOptions:
{ plugins:
['postcss-preset-env', {'browsers': ['last 2 versions', 'ie >= 9', 'android >= 4.4', 'ios >= 7']}]}}},
2020-10-29 23:59:31 +00:00
// Compiles Sass to CSS
'sass-loader',
]
}]
2020-10-26 16:17:00 +00:00
}
};