Skip to content

Instantly share code, notes, and snippets.

@SherryH
Created June 1, 2018 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SherryH/a2e25df83bd4d84dddcad58917f0b6b6 to your computer and use it in GitHub Desktop.
Save SherryH/a2e25df83bd4d84dddcad58917f0b6b6 to your computer and use it in GitHub Desktop.
const extractSCSS = new ExtractTextPlugin({
filename: 'stylesheets/main.css',
disable: IS_DEV,
allChunks: true
});
const extractCSS = new ExtractTextPlugin({
filename: 'stylesheets/vendor.css',
disable: IS_DEV,
allChunks: true
});
module.exports = {
context,
entry: { main: path.join(__dirname, './src/index.js') },
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/assets',
filename: '[name].[chunkhash:4].js'
},
module: {
rules: [
{
test: /\.css$/,
use: extractCSS.extract({
fallback: 'style-loader',
use: [{ loader: 'css-loader', options: { minimize: !IS_DEV } }, { loader: 'postcss-loader' }]
})
},
{
test: /\.(scss|sass)$/,
include: [path.resolve(__dirname, './src/common/'), path.resolve(__dirname, 'node_modules', 'bulma')],
use: extractSCSS.extract({ fallback: 'style-loader', use: ['css-loader', 'postcss-loader', 'sass-loader'] })
},
{
test: /\.scss$/,
exclude: [path.resolve(__dirname, './src/common/'), path.resolve(__dirname, 'node_modules', 'bulma')],
use: extractSCSS.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, 'src', 'common')]
}
}
]
})
}
]
},
plugins: [
extractSCSS,
extractCSS,
new HtmlWebpackPlugin({
title: 'Form Builder',
template: path.join(__dirname, '/static/template.html')
}),
new CleanWebpackPlugin(['dist'])
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment