Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
let plugins =
[
new EnvironmentPlugin(['NODE_ENV']),
new ProgressPlugin({ profile: false })
]
try {
const VENDOR_MANIFEST = require('./vendor-manifest.json');
plugins.push(new DllReferencePlugin({
manifest: VENDOR_MANIFEST
}));
} catch (e) {
//This should never happen. Vendor-manifest is built prior to files being built. But it's here just in case.
console.error(`[WEBPACK ERROR:] You have not generated a vendor-manifest for your webpack configuration. This is an important optimization that reduces build times by 30-40%. Please run "npm run build:vendor-manifest", and then run "npm run dev" once more. You are required to build the vendor manifest when you delete your dist folder, when your node modules update, or when you update the Finsemble Seed project.`);
process.exit(1);
}
if (env === "production") {
// When building the production environment, minify the code.
plugins.push(new UglifyJsPlugin());
} else {
plugins.push(new hardSource({
//root dir here is "dist". Back out so we dump this file into the root.
cacheDirectory: '../.webpack-file-cache/[confighash]',
// Either an absolute path or relative to webpack's options.context.
function useWebpackDll() {
console.log("Using Webpack DLL vendor bundle");
const jsonPath = path.join('..', settings.frontendBuildDir, 'vendor_dll.json');
clientConfig.plugins.push(new webpack.DllReferencePlugin({
context: process.cwd(),
manifest: require(jsonPath) // eslint-disable-line import/no-dynamic-require
}));
serverConfig.plugins.push(new webpack.DllReferencePlugin({
context: process.cwd(),
manifest: require(jsonPath) // eslint-disable-line import/no-dynamic-require
}));
}
// names: ["common", "manifest"]
// }),
new (require('chunk-manifest-webpack-plugin'))({
filename: "manifest.json",
manifestVariable: "webpackManifest"
}),
//breaks incremental updates in watch mode...
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin("[name]-[contenthash].css")
);
}
plugins.push(
new webpack.DllReferencePlugin({
manifest: require(fullPath("../target/vendors-manifest.json")),
context: fullPath("../src")
}));
return plugins;
}
function startDevServer() {
const app = express();
const devConfig = getConfig('dev');
devConfig.plugins.push(new webpack.DllReferencePlugin({
context: srcPath,
manifest: require(manifestPath),
}));
const compiler = webpack(devConfig);
app.use(devMiddleware(compiler, {
publicPath: devConfig.output.publicPath,
historyApiFallback: true,
}));
app.use(hotMiddleware(compiler));
// First, find files from src folder
app.use(express.static(path.join(__dirname, '../src')));
// Also support files from root folder, mainly for the dev-vendor bundle
function startDevServer() {
devConfig.entry = {
main: [
`webpack-dev-server/client?http://localhost:${PORT}`,
'webpack/hot/only-dev-server',
'./styles/index.less',
'./index',
],
};
devConfig.plugins.push(new webpack.DllReferencePlugin({
context: srcPath,
manifest: require(manifestPath),
}));
new WebpackDevServer(webpack(devConfig), {
publicPath: devConfig.output.publicPath,
contentBase: devConfig.devServer.contentBase,
hot: true,
noInfo: false,
quiet: false,
https: false,
historyApiFallback: true,
}).listen(PORT, (err) => {
if (err) {
console.log(err);
}
console.log(`Listening at localhost:${PORT}`);
new CheckerPlugin(),
new DefinePlugin(CONSTANTS),
new NamedModulesPlugin(),
new FilterWarningsPlugin({
exclude: /System\.import/,
}),
...MY_CLIENT_PLUGINS,
];
if (DEV_SERVER) {
config.plugins.push(
new DllReferencePlugin({
context: '.',
manifest: require(`./dll/polyfill-manifest.json`),
}),
new DllReferencePlugin({
context: '.',
manifest: require(`./dll/vendor-manifest.json`),
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: false,
})
);
}
if (DLL) {
config.plugins.push(
new DllPlugin({
name: '[name]',
path: root('dll/[name]-manifest.json'),
})
{from: path.join(__dirname, "../build/" + dllManifest.name + ".js")}
])
);
config.plugins.push(
new HtmlWebpackPlugin({
filename: "index.html",
template: path.join(__dirname, "../src/index.html"),
inject: false,
chunksSortMode: "none",
dlls: [
dllManifest.name + ".js"
]
})
);
config.plugins.push(
new webpack.DllReferencePlugin({
manifest: path.join(__dirname, "../build/manifest.json"),
})
);
if (process.env.NODE_ENV === webpackBase.ENV_PRODUCTION) {
config.entry = [
path.join(__dirname, '../src/spa.js')
];
config.plugins.push(
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[id].[hash].css'
})
);
}
else {
const dllLibs = require('../../builds/client/libs.json')
//Remove semantic if in theme mode
if (process.env.THEME){
delete dllLibs.content['./node_modules/semantic-ui-less/semantic.less']
}
//Add dll connection plugins
setup.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.DllReferencePlugin({
context: '.',
manifest: require('../../builds/client/vendor.json')
}),
new webpack.DllReferencePlugin({
context: '.',
manifest: dllLibs
})
)
}
}
//Add css collectors
if (!(process.env.NODE_ENV === 'development' && !process.env.THEME && !libs)){
setup.plugins.push(new WebpackExtractText({
filename: 'style.css',
allChunks: true
}))
}
//Add source map plugins for development
}
/**
* loader config
* @type {RegExp}
*/
config.module.loaders.push({
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.scss$/,
loader: 'style!css!sass'
});
config.plugins.push(
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require(path.resolve(publicPath,'react-manifest.json')),
name:'react_library'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('[name].css'),
new BrowserSyncPlugin({
host: '127.0.0.1',
port: 9090,
proxy: 'http://127.0.0.1:9000/',
logConnections: false,
notify: false
}, {
reload: false