2017-08-07 04:32:07 +02:00
|
|
|
const path = require('path');
|
2017-08-16 06:47:34 +02:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2017-08-24 23:54:02 +02:00
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
2017-08-07 04:32:07 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
2017-08-26 00:12:16 +02:00
|
|
|
vendor: ['babel-polyfill', 'fluent'],
|
2017-08-24 23:54:02 +02:00
|
|
|
app: ['./app/main.js']
|
2017-08-07 04:32:07 +02:00
|
|
|
},
|
|
|
|
output: {
|
2017-08-24 23:54:02 +02:00
|
|
|
filename: '[name].[chunkhash:8].js',
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2017-08-10 04:22:20 +02:00
|
|
|
publicPath: '/'
|
2017-08-07 04:32:07 +02:00
|
|
|
},
|
|
|
|
module: {
|
2017-08-14 21:04:03 +02:00
|
|
|
rules: [
|
2017-08-07 04:32:07 +02:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2017-08-14 21:04:03 +02:00
|
|
|
loader: 'babel-loader',
|
2017-08-09 21:56:32 +02:00
|
|
|
include: [
|
2017-08-24 23:54:02 +02:00
|
|
|
path.resolve(__dirname, 'app'),
|
|
|
|
path.resolve(__dirname, 'common'),
|
2017-08-09 21:56:32 +02:00
|
|
|
path.resolve(__dirname, 'node_modules/testpilot-ga/src')
|
|
|
|
],
|
2017-08-14 21:04:03 +02:00
|
|
|
options: {
|
2017-08-09 21:56:32 +02:00
|
|
|
babelrc: false,
|
2017-08-24 23:54:02 +02:00
|
|
|
presets: [['env', { modules: false }], 'stage-2'],
|
|
|
|
plugins: ['yo-yoify']
|
2017-08-09 21:56:32 +02:00
|
|
|
}
|
2017-08-16 06:47:34 +02:00
|
|
|
},
|
2017-08-24 23:54:02 +02:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
include: [path.dirname(require.resolve('fluent'))],
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: 'fluent'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [['env', { modules: false }]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('./assets/cryptofill'),
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[hash:8].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2017-08-16 06:47:34 +02:00
|
|
|
{
|
|
|
|
test: /\.(svg|png|jpg)$/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2017-08-24 23:54:02 +02:00
|
|
|
name: '[name].[hash:8].[ext]'
|
2017-08-16 06:47:34 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2017-08-24 23:54:02 +02:00
|
|
|
name: '[name].[hash:8].[ext]'
|
2017-08-16 06:47:34 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
'extract-loader',
|
|
|
|
{ loader: 'css-loader', options: { importLoaders: 1 } },
|
|
|
|
'postcss-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2017-08-24 23:54:02 +02:00
|
|
|
test: require.resolve('./package.json'),
|
2017-08-16 06:47:34 +02:00
|
|
|
use: [
|
|
|
|
{
|
2017-08-24 23:54:02 +02:00
|
|
|
loader: 'file-loader',
|
2017-08-16 06:47:34 +02:00
|
|
|
options: {
|
2017-08-24 23:54:02 +02:00
|
|
|
name: 'version.json'
|
2017-08-16 06:47:34 +02:00
|
|
|
}
|
2017-08-24 23:54:02 +02:00
|
|
|
},
|
|
|
|
'extract-loader',
|
|
|
|
'./build/package_json_loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ftl$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[path][name].[hash:8].js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'extract-loader',
|
|
|
|
'./build/fluent_loader'
|
2017-08-16 06:47:34 +02:00
|
|
|
]
|
2017-08-24 23:54:02 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('./build/generate_asset_map.js'),
|
|
|
|
use: ['babel-loader', 'val-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('./build/generate_l10n_map.js'),
|
|
|
|
use: ['babel-loader', 'val-loader']
|
2017-08-07 04:32:07 +02:00
|
|
|
}
|
|
|
|
]
|
2017-08-15 20:55:52 +02:00
|
|
|
},
|
2017-08-16 06:47:34 +02:00
|
|
|
plugins: [
|
|
|
|
new CopyPlugin([
|
|
|
|
{
|
|
|
|
context: 'public',
|
|
|
|
from: '*.*'
|
|
|
|
}
|
|
|
|
]),
|
2017-08-24 23:54:02 +02:00
|
|
|
new webpack.IgnorePlugin(/dist/),
|
|
|
|
new webpack.IgnorePlugin(/require-from-string/),
|
2017-08-16 06:47:34 +02:00
|
|
|
new webpack.HashedModuleIdsPlugin(),
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
2017-08-26 00:12:16 +02:00
|
|
|
name: 'vendor',
|
|
|
|
minChunks: ({ resource }) => /node_modules/.test(resource)
|
2017-08-16 06:47:34 +02:00
|
|
|
}),
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: 'runtime'
|
2017-08-24 23:54:02 +02:00
|
|
|
}),
|
|
|
|
new ManifestPlugin()
|
|
|
|
],
|
|
|
|
devServer: {
|
|
|
|
compress: true,
|
|
|
|
setup:
|
|
|
|
process.env.NODE_ENV === 'development'
|
|
|
|
? require('./server/dev')
|
|
|
|
: undefined
|
|
|
|
}
|
2017-08-07 04:32:07 +02:00
|
|
|
};
|