Skip to content

Instantly share code, notes, and snippets.

@iCodeForBananas
Created January 2, 2017 23:25
Show Gist options
  • Save iCodeForBananas/ecaef6d47c0755a96be8f71bfe1b1f88 to your computer and use it in GitHub Desktop.
Save iCodeForBananas/ecaef6d47c0755a96be8f71bfe1b1f88 to your computer and use it in GitHub Desktop.
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const ASSET_PATH = 'resources/assets'
const APP_FILE_PATH = './resources/assets/js/app.js'
const PUBLIC_PATH = 'public'
module.exports = function() {
return {
entry: APP_FILE_PATH,
output: {
path: PUBLIC_PATH,
filename: 'js/app.js',
publicPath: '/',
},
resolve: {
alias: {
lib: path.resolve('./lib'),
'react': 'preact-compat',
'react-dom': 'preact-compat',
'actions': path.resolve('./resources/assets/js/actions/'),
},
extensions: ['.scss', '.webpack.js', '.web.js', '.js'],
},
module: {
loaders: [
{
test:/\.(js|jsx)$/,
include: [
path.join(__dirname, `${ASSET_PATH}/js`),
path.resolve('node_modules/preact-compat/src'),
],
loader: 'babel-loader',
},
{
test: /\.scss$/,
include: [ path.join(__dirname, `${ASSET_PATH}/sass/app.scss`) ],
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: 'css!sass',
}),
},
],
},
}
}
const webpackMerge = require('webpack-merge')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeJsPlugin = require('optimize-js-plugin')
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
const commonConfig = require('./base.js')
module.exports = function (env) {
return webpackMerge(commonConfig(), {
devtool: 'eval-source-map',
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
proxy: {
target: 'http://localhost:3000',
ws: true,
},
}),
new ExtractTextPlugin({
filename: 'css/app.css',
allChunks: true,
disable: false,
}),
new OptimizeJsPlugin({
sourceMap: false,
}),
],
})
}
const webpackMerge = require('webpack-merge')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeJsPlugin = require('optimize-js-plugin')
const JavaScriptObfuscator = require('webpack-obfuscator')
const commonConfig = require('./base.js')
module.exports = function (env) {
return webpackMerge(commonConfig(), {
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': `'production'`,
},
}),
new ExtractTextPlugin({
filename: 'css/app.css',
allChunks: true,
disable: false,
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
mangle: true,
minimize: true,
compressor: {
warnings: false,
screw_ie8: true,
},
}),
new OptimizeJsPlugin({
sourceMap: false,
}),
new JavaScriptObfuscator({
selfDefending: true,
}),
],
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment