joyce/webpack.common.js

98 lines
2.1 KiB
JavaScript
Raw Normal View History

const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const ManifestRevisionPlugin = require('manifest-revision-webpack-plugin')
const webpack = require('webpack')
const path = require('path')
const rootAssetPath = './src/'
let pathsToClean = [
2017-12-16 20:01:30 +00:00
'static/js'
]
module.exports = {
entry: {
reader: [
rootAssetPath + 'reader',
rootAssetPath + 'stylesheets/' + 'reader.scss'
],
editor: [
rootAssetPath + 'editor',
rootAssetPath + 'stylesheets/' + 'editor.scss'
2017-12-16 20:01:30 +00:00
],
2017-12-16 20:17:57 +00:00
notes: [
rootAssetPath + 'notes',
rootAssetPath + 'stylesheets/' + 'reader.scss'
],
2017-12-16 20:01:30 +00:00
search: [
rootAssetPath + 'search',
rootAssetPath + 'stylesheets/' + 'search.scss'
]
},
// output: {
// publicPath: "/static/js/",
// filename: '[name].[hash].js',
// path: path.resolve(__dirname, 'static/js/')
// },
module : {
rules: [
{
test: /\.(js)$/,
2018-04-19 23:45:43 +00:00
exclude: [
/node_modules/,
/\.DS_Store/
2018-04-19 23:45:43 +00:00
],
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'react']
}
}
},
{
test: /\.(png)$/,
use: {
loader: 'file-loader'
}
},
{
test: /\.(scss)$/,
2018-04-19 23:45:43 +00:00
exclude: [
/node_modules/,
/\.DS_Store/
2018-04-19 23:45:43 +00:00
],
use: [{
2018-04-19 23:45:43 +00:00
loader: 'style-loader',
}, {
2018-04-19 23:45:43 +00:00
loader: 'css-loader',
}, {
2018-04-19 23:45:43 +00:00
loader: 'postcss-loader',
options: {
plugins: [
require('precss'),
require('autoprefixer')
]
}
}, {
loader: 'sass-loader' // compiles SASS to CSS
}]
},
{
2018-04-19 23:45:43 +00:00
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader'
}]
}
]},
plugins: [
new ManifestRevisionPlugin(path.join('static/', 'manifest.json'), {
rootAssetPath: rootAssetPath
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
}),
new CleanWebpackPlugin(pathsToClean),
],
};