ocrcc-chatbox/webpack.config.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-05-26 18:53:54 +00:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
mode: 'development',
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
2018-05-29 02:49:38 +00:00
}),
2018-05-26 18:53:54 +00:00
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
2018-05-29 02:49:38 +00:00
use: ['babel-loader'],
2018-05-26 18:53:54 +00:00
},
{
test: /\.scss$/,
use: [
// fallback to style-loader in development
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
2018-05-29 02:49:38 +00:00
'sass-loader',
],
},
],
2018-05-26 18:53:54 +00:00
},
resolve: {
2018-05-29 02:49:38 +00:00
extensions: ['*', '.js', '.jsx'],
2018-05-26 18:53:54 +00:00
},
entry: [
2018-05-29 02:49:38 +00:00
'./src/index.js',
2018-05-26 18:53:54 +00:00
],
output: {
path: __dirname + '/dist',
publicPath: '/',
2018-05-29 02:49:38 +00:00
filename: 'embeddable-widget.js',
library: 'EmbeddableWidget',
libraryExport: 'default',
libraryTarget: 'window',
2018-05-26 18:53:54 +00:00
},
serve: {
2018-05-29 02:49:38 +00:00
content: ['./dist', './public'],
},
2018-05-26 18:53:54 +00:00
};