Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plugins: [
'transform-object-rest-spread',
'transform-class-properties'
],
babelrc: false,
cacheDirectory: false
}
},
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
]
},
plugins: removeEmpty([
new ProgressBarPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: env === 'production' ? '"production"' : '"development"'
}
})
])
}
if (env === 'development') {
// Create new entry object with webpack-hot-middleware and react-hot-loader (if enabled)
if (!hot || hot.enabled !== false) {
for (let key in entries) {
const entry = []
const hotMiddleware = `webpack-hot-middleware/client?${querystring.stringify(
hot
chunks.push(plugin)
})
/*
|--------------------------------------------------------------------------
| return webpack config object
|--------------------------------------------------------------------------
*/
export default {
// we have to use source map for css source maps, slightly longer compile times
// devtool: 'source-map',
context: BASE_PATH,
// entry is a function so that we can use environment variables
entry: removeEmpty(entryPoints),
output: {
path: outputPath,
publicPath: '',
filename: ifProduction(
assetsPath('js/[name].js')
),
chunkFilename: assetsPath('js/[id].js')
},
resolve: {
extensions: ['.js', '.json', '.vue'],
modules: [resolve(config.src.base), resolve('node_modules')],
alias: {
src: resolve(config.src.base)
}
},
module: {
loader: 'file-loader',
options: {
name: ifProduction(
'assets/fonts/[name].[hash:8].[ext]',
'assets/fonts/[name].[ext]'
)
}
}
},
{
test: /\.json/,
use: 'json-loader'
}
]
},
plugins: removeEmpty([
new webpack.DefinePlugin({
__LORE_ROOT__: JSON.stringify(__dirname),
'process.env': {
'NODE_ENV': JSON.stringify(env)
}
}),
new ProgressBarPlugin(),
new ExtractTextPlugin(ifProduction(
'styles.[name].[chunkhash].css',
'styles.[name].css'
)),
ifProduction(new ManifestPlugin({
fileName: 'asset-manifest.json'
})),
ifProduction(new webpack.optimize.CommonsChunkPlugin({
names: [
loader: 'file-loader',
options: {
name: ifProduction(
'assets/fonts/[name].[hash:8].[ext]',
'assets/fonts/[name].[ext]'
)
}
}
},
{
test: /\.json/,
use: 'json-loader'
}
]
},
plugins: removeEmpty([
new webpack.DefinePlugin({
__LORE_ROOT__: JSON.stringify(__dirname),
'process.env': {
'NODE_ENV': JSON.stringify(env)
}
}),
new ProgressBarPlugin(),
new ExtractTextPlugin(ifProduction(
'styles.[name].[chunkhash].css',
'styles.[name].css'
)),
ifProduction(new ManifestPlugin({
fileName: 'asset-manifest.json'
})),
ifProduction(new webpack.optimize.CommonsChunkPlugin({
names: [
loader: 'file-loader',
options: {
name: ifProduction(
'assets/fonts/[name].[hash:8].[ext]',
'assets/fonts/[name].[ext]'
)
}
}
},
{
test: /\.json/,
use: 'json-loader'
}
]
},
plugins: removeEmpty([
new webpack.DefinePlugin({
__LORE_ROOT__: JSON.stringify(__dirname),
'process.env': {
'NODE_ENV': JSON.stringify(env)
}
}),
new ProgressBarPlugin(),
new ExtractTextPlugin(ifProduction(
'styles.[name].[chunkhash].css',
'styles.[name].css'
)),
ifProduction(new ManifestPlugin({
fileName: 'asset-manifest.json'
})),
ifProduction(
new webpack.optimize.CommonsChunkPlugin({
loader: 'file-loader',
options: {
name: ifProduction(
'assets/fonts/[name].[hash:8].[ext]',
'assets/fonts/[name].[ext]'
)
}
}
},
{
test: /\.json/,
use: 'json-loader'
}
]
},
plugins: removeEmpty([
new webpack.DefinePlugin({
__LORE_ROOT__: JSON.stringify(__dirname),
__BASENAME__: JSON.stringify(BASENAME),
'process.env': {
'LORE_ENV': JSON.stringify(env.lore || env),
'NODE_ENV': JSON.stringify(env.webpack || env)
}
}),
new ProgressBarPlugin(),
new ExtractTextPlugin(ifProduction(
'styles.[name].[chunkhash].css',
'styles.[name].css'
)),
ifProduction(new ManifestPlugin({
fileName: 'asset-manifest.json'
})),
loader: 'file-loader',
options: {
name: ifProduction(
'assets/fonts/[name].[hash:8].[ext]',
'assets/fonts/[name].[ext]'
)
}
}
},
{
test: /\.json/,
use: 'json-loader'
}
]
},
plugins: removeEmpty([
new webpack.DefinePlugin({
__LORE_ROOT__: JSON.stringify(__dirname),
'process.env': {
'NODE_ENV': JSON.stringify(env)
}
}),
new ProgressBarPlugin(),
new ExtractTextPlugin(ifProduction(
'styles.[name].[chunkhash].css',
'styles.[name].css'
)),
ifProduction(new ManifestPlugin({
fileName: 'asset-manifest.json'
})),
ifProduction(new webpack.optimize.CommonsChunkPlugin({
names: [
export default ({ projectRoot, appRoot, urlGenerator }) => {
const definePlugin = new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
});
const plugins = removeEmpty([
definePlugin,
ifProduction(new ModuleIdsPlugin()),
ifProduction(new ChunkIdsPlugin({ projectRoot })),
ifProduction(new AssetFileNamePlugin()),
ifDevelopment(new webpack.NoEmitOnErrorsPlugin()),
ifDevelopment(new webpack.HotModuleReplacementPlugin()),
new ExtractTextPlugin("styles.css"),
new AssetsMetaPlugin({ projectRoot, urlGenerator }),
ifDevelopment(new webpack.NamedModulesPlugin()),
ifProduction(new webpack.optimize.ModuleConcatenationPlugin()),
ifProduction(new webpack.HashedModuleIdsPlugin()),
ifProduction(new UglifyJsPlugin()),
ifProduction(
new OptimizeCssAssetsPlugin({
canPrint: false,
assetNameRegExp: /\.css$/,
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
]
},
plugins: removeEmpty([
new ProgressBarPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: env === 'production' ? '"production"' : '"development"'
}
}),
new InjectManifest({
globDirectory: path.resolve(
process.env.PWD,
PATH_CONFIG.public,
'dist'
),
globPatterns: ['**/*.{html,js,css,svg,png}'],
globIgnores: ['theme.*.css'],
export function getEntry(environment: string, publicPath: string): Entry {
const { ifDevelopment } = getIfUtils(environment);
const hmrPath = path.normalize(`/${publicPath}/__webpack_hmr`);
return {
main: removeEmpty([
require.resolve("@babel/polyfill"),
ifDevelopment(
`webpack-hot-middleware/client?path=${hmrPath}`,
undefined,
),
resolvePath("src/client/index.tsx"),
]),
}
}