Skip to content

Instantly share code, notes, and snippets.

@AnandShiva
Last active September 14, 2020 09:14
Show Gist options
  • Save AnandShiva/804187e6ac054394808115eb51587d8c to your computer and use it in GitHub Desktop.
Save AnandShiva/804187e6ac054394808115eb51587d8c to your computer and use it in GitHub Desktop.
Vue Enabled webpack.js
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const ExtensionReloader = require('webpack-extension-reloader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { VueLoaderPlugin } = require('vue-loader');
module.exports = {
context: path.resolve(__dirname, 'src'),
entry: {
'newTab': './newTab.js',
'background': './background.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
'@': `${__dirname}/src`,
vue$: 'vue/dist/vue.esm.js',
},
},
module: {
rules: [
{
test: /\.vue$/,
loaders: 'vue-loader',
},
{
test: /\.js$/,
loaders: 'babel-loader',
exclude: /node_modules/,
},
// to read the css files
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
// to read the sass style block in vue files.
{
test: /\.sass$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
// to read the scss style block in vue files.
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
],
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin(),
new ExtensionReloader({
manifest: path.resolve(__dirname,'src', "manifest.json"),
entries: {
background: 'background' // *REQUIRED
}
}),
new CopyPlugin({
patterns: [
{ from: 'manifest.json', to: 'manifest.json' },
{ from: 'newTab.html', to: 'newTab.html' }
],
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment