toodle/webextension/webpack.config.js

50 строки
1.1 KiB
JavaScript

/* global __dirname:true, process:true */
/* eslint-env commonjs */
const path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'extension/dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [ 'css-loader' ]
})
}
]
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
path.resolve(__dirname, 'src'),
'node_modules',
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
new ExtractTextPlugin('app.css'),
],
devtool: NODE_ENV === 'production' ? 'cheap-module-source-map' : 'source-map'
};